[database][android] misc cleanup from previous iterations of listener registration logic
This commit is contained in:
parent
aebd1835bc
commit
8958e47e36
|
@ -382,12 +382,12 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
* @param key
|
* @param key
|
||||||
* @param path
|
* @param path
|
||||||
* @param modifiers
|
* @param modifiers
|
||||||
* @param eventName
|
* @param eventType
|
||||||
* @param promise
|
* @param promise
|
||||||
*/
|
*/
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void once(String appName, String key, String path, ReadableArray modifiers, String eventName, Promise promise) {
|
public void once(String appName, String key, String path, ReadableArray modifiers, String eventType, Promise promise) {
|
||||||
getInternalReferenceForApp(appName, key, path, modifiers).once(eventName, promise);
|
getInternalReferenceForApp(appName, key, path, modifiers).once(eventType, promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -400,7 +400,6 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
public void on(String appName, ReadableMap props) {
|
public void on(String appName, ReadableMap props) {
|
||||||
getInternalReferenceForApp(appName, props)
|
getInternalReferenceForApp(appName, props)
|
||||||
.on(
|
.on(
|
||||||
this,
|
|
||||||
props.getString("eventType"),
|
props.getString("eventType"),
|
||||||
props.getMap("registration")
|
props.getMap("registration")
|
||||||
);
|
);
|
||||||
|
|
|
@ -82,7 +82,8 @@ class RNFirebaseDatabaseReference {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* Remove an event listener by key, will remove either a ValueEventListener or
|
||||||
|
* a ChildEventListener
|
||||||
*
|
*
|
||||||
* @param eventRegistrationKey
|
* @param eventRegistrationKey
|
||||||
*/
|
*/
|
||||||
|
@ -204,28 +205,27 @@ class RNFirebaseDatabaseReference {
|
||||||
/**
|
/**
|
||||||
* Handles a React Native JS '.on(..)' request and initializes listeners.
|
* Handles a React Native JS '.on(..)' request and initializes listeners.
|
||||||
*
|
*
|
||||||
* @param database
|
|
||||||
* @param registration
|
* @param registration
|
||||||
*/
|
*/
|
||||||
void on(RNFirebaseDatabase database, String eventType, ReadableMap registration) {
|
void on(String eventType, ReadableMap registration) {
|
||||||
if (eventType.equals("value")) {
|
if (eventType.equals("value")) {
|
||||||
addValueEventListener(registration, database);
|
addValueEventListener(registration);
|
||||||
} else {
|
} else {
|
||||||
addChildEventListener(registration, eventType, database);
|
addChildEventListener(registration, eventType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a React Native JS 'once' request.
|
* Handles a React Native JS 'once' request.
|
||||||
*
|
*
|
||||||
* @param eventName
|
* @param eventType
|
||||||
* @param promise
|
* @param promise
|
||||||
*/
|
*/
|
||||||
void once(String eventName, Promise promise) {
|
void once(String eventType, Promise promise) {
|
||||||
if (eventName.equals("value")) {
|
if (eventType.equals("value")) {
|
||||||
addOnceValueEventListener(promise);
|
addOnceValueEventListener(promise);
|
||||||
} else {
|
} else {
|
||||||
addChildOnceEventListener(eventName, promise);
|
addChildOnceEventListener(eventType, promise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,9 +235,8 @@ class RNFirebaseDatabaseReference {
|
||||||
*
|
*
|
||||||
* @param registration
|
* @param registration
|
||||||
* @param eventType
|
* @param eventType
|
||||||
* @param database
|
|
||||||
*/
|
*/
|
||||||
private void addChildEventListener(final ReadableMap registration, final String eventType, final RNFirebaseDatabase database) {
|
private void addChildEventListener(final ReadableMap registration, final String eventType) {
|
||||||
final String eventRegistrationKey = registration.getString("eventRegistrationKey");
|
final String eventRegistrationKey = registration.getString("eventRegistrationKey");
|
||||||
final String registrationCancellationKey = registration.getString("registrationCancellationKey");
|
final String registrationCancellationKey = registration.getString("registrationCancellationKey");
|
||||||
|
|
||||||
|
@ -286,11 +285,9 @@ class RNFirebaseDatabaseReference {
|
||||||
* Add a native .on('value',.. ) event listener.
|
* Add a native .on('value',.. ) event listener.
|
||||||
*
|
*
|
||||||
* @param registration
|
* @param registration
|
||||||
* @param database
|
|
||||||
*/
|
*/
|
||||||
private void addValueEventListener(final ReadableMap registration, final RNFirebaseDatabase database) {
|
private void addValueEventListener(final ReadableMap registration) {
|
||||||
final String eventRegistrationKey = registration.getString("eventRegistrationKey");
|
final String eventRegistrationKey = registration.getString("eventRegistrationKey");
|
||||||
final String registrationCancellationKey = registration.getString("registrationCancellationKey");
|
|
||||||
|
|
||||||
if (!hasEventListener(eventRegistrationKey)) {
|
if (!hasEventListener(eventRegistrationKey)) {
|
||||||
ValueEventListener valueEventListener = new ValueEventListener() {
|
ValueEventListener valueEventListener = new ValueEventListener() {
|
||||||
|
|
Loading…
Reference in New Issue