Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f484cbd

Browse files
committed
Android: Fix .on() listeners not getting removed / called immediately on setup
1 parent 54a564c commit f484cbd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

android/src/main/java/io/fullstack/firestack/FirestackDatabase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ public void off(final String path, final String name, final Callback callback) {
468468
ref.removeChildEventListener();
469469
}
470470

471-
this.removeDBHandle(path, name);
471+
String key = this.keyPath(path, name);
472+
this.removeDBHandle(key);
472473
Log.d(TAG, "Removed listener " + name);
473474
WritableMap resp = Arguments.createMap();
474475
resp.putString("handle", path);
@@ -583,12 +584,11 @@ private void saveDBHandle(final String path,
583584
final String eventName,
584585
final FirestackDBReference dbRef) {
585586
String key = this.keyPath(path, eventName);
586-
this.removeDBHandle(key, eventName);
587+
this.removeDBHandle(key);
587588
mDBListeners.put(key, dbRef);
588589
}
589590

590-
private void removeDBHandle(final String path, final String eventName) {
591-
String key = this.keyPath(path, eventName);
591+
private void removeDBHandle(final String key) {
592592
if (mDBListeners.containsKey(key)) {
593593
FirestackDBReference r = mDBListeners.get(key);
594594
r.cleanup();

0 commit comments

Comments
 (0)