[android][database] updated keepSynced to now work with modifiers
This commit is contained in:
parent
6298b86557
commit
913bb4e500
|
@ -73,9 +73,10 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
* @param state
|
* @param state
|
||||||
*/
|
*/
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void keepSynced(String appName, String path, Boolean state) {
|
public void keepSynced(String appName, int id, String path, ReadableArray modifiers, Boolean state) {
|
||||||
// TODO: Needs to take into account modifiers as well as just the path
|
getInternalReferenceForApp(appName, id, path, modifiers, false)
|
||||||
getReferenceForAppPath(appName, path).keepSynced(state);
|
.getQuery()
|
||||||
|
.keepSynced(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -406,8 +407,6 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* INTERNALS/UTILS
|
* INTERNALS/UTILS
|
||||||
*/
|
*/
|
||||||
|
@ -441,6 +440,11 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
return "RNFirebaseDatabase";
|
return "RNFirebaseDatabase";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* React Native constants for RNFirebaseDatabase
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getConstants() {
|
public Map<String, Object> getConstants() {
|
||||||
final Map<String, Object> constants = new HashMap<>();
|
final Map<String, Object> constants = new HashMap<>();
|
||||||
|
@ -471,6 +475,8 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Return an existing or create a new RNFirebaseDatabaseReference instance.
|
||||||
|
*
|
||||||
* @param appName
|
* @param appName
|
||||||
* @param refId
|
* @param refId
|
||||||
* @param path
|
* @param path
|
||||||
|
@ -520,6 +526,13 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
return service.toUpperCase() + "/" + code.toUpperCase();
|
return service.toUpperCase() + "/" + code.toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert as firebase DatabaseError instance into a writable map
|
||||||
|
* with the correct web-like error codes.
|
||||||
|
*
|
||||||
|
* @param nativeError
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
static WritableMap getJSError(DatabaseError nativeError) {
|
static WritableMap getJSError(DatabaseError nativeError) {
|
||||||
WritableMap errorMap = Arguments.createMap();
|
WritableMap errorMap = Arguments.createMap();
|
||||||
errorMap.putInt("nativeErrorCode", nativeError.getCode());
|
errorMap.putInt("nativeErrorCode", nativeError.getCode());
|
||||||
|
|
|
@ -33,6 +33,10 @@ public class RNFirebaseDatabaseReference {
|
||||||
private SparseArray<ChildEventListener> childEventListeners;
|
private SparseArray<ChildEventListener> childEventListeners;
|
||||||
private SparseArray<ValueEventListener> valueEventListeners;
|
private SparseArray<ValueEventListener> valueEventListeners;
|
||||||
|
|
||||||
|
Query getQuery() {
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param context
|
* @param context
|
||||||
* @param app
|
* @param app
|
||||||
|
@ -45,11 +49,8 @@ public class RNFirebaseDatabaseReference {
|
||||||
appName = app;
|
appName = app;
|
||||||
path = refPath;
|
path = refPath;
|
||||||
reactContext = context;
|
reactContext = context;
|
||||||
|
|
||||||
// todo only create if needed
|
|
||||||
childEventListeners = new SparseArray<ChildEventListener>();
|
childEventListeners = new SparseArray<ChildEventListener>();
|
||||||
valueEventListeners = new SparseArray<ValueEventListener>();
|
valueEventListeners = new SparseArray<ValueEventListener>();
|
||||||
|
|
||||||
query = buildDatabaseQueryAtPathAndModifiers(path, modifiersArray);
|
query = buildDatabaseQueryAtPathAndModifiers(path, modifiersArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ public class RNFirebaseDatabaseReference {
|
||||||
*
|
*
|
||||||
* @param promise
|
* @param promise
|
||||||
*/
|
*/
|
||||||
void addOnceValueEventListener(final Promise promise) {
|
private void addOnceValueEventListener(final Promise promise) {
|
||||||
ValueEventListener onceValueEventListener = new ValueEventListener() {
|
ValueEventListener onceValueEventListener = new ValueEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDataChange(DataSnapshot dataSnapshot) {
|
public void onDataChange(DataSnapshot dataSnapshot) {
|
||||||
|
@ -83,7 +84,7 @@ public class RNFirebaseDatabaseReference {
|
||||||
* @param eventName
|
* @param eventName
|
||||||
* @param promise
|
* @param promise
|
||||||
*/
|
*/
|
||||||
void addChildOnceEventListener(final String eventName, final Promise promise) {
|
private void addChildOnceEventListener(final String eventName, final Promise promise) {
|
||||||
ChildEventListener childEventListener = new ChildEventListener() {
|
ChildEventListener childEventListener = new ChildEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) {
|
public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) {
|
||||||
|
@ -132,12 +133,16 @@ public class RNFirebaseDatabaseReference {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a React Native JS 'on' request and initializes listeners.
|
||||||
|
* @param eventName
|
||||||
|
*/
|
||||||
void on(String eventName) {
|
void on(String eventName) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Handles a React Native JS 'once' request.
|
||||||
* @param eventName
|
* @param eventName
|
||||||
* @param promise
|
* @param promise
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue