Merge pull request #528 from rmrs/rumors
Workaround for null reference of database reference off
This commit is contained in:
commit
728173c7f1
|
@ -416,12 +416,14 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void off(String key, String eventRegistrationKey) {
|
public void off(String key, String eventRegistrationKey) {
|
||||||
RNFirebaseDatabaseReference nativeRef = references.get(key);
|
RNFirebaseDatabaseReference nativeRef = references.get(key);
|
||||||
|
if (nativeRef != null) {
|
||||||
nativeRef.removeEventListener(eventRegistrationKey);
|
nativeRef.removeEventListener(eventRegistrationKey);
|
||||||
|
|
||||||
if (!nativeRef.hasListeners()) {
|
if (!nativeRef.hasListeners()) {
|
||||||
references.remove(key);
|
references.remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* INTERNALS/UTILS
|
* INTERNALS/UTILS
|
||||||
|
|
Loading…
Reference in New Issue