@@ -159,7 +159,7 @@ public void onComplete(DatabaseError error, DatabaseReference ref) {
159
159
} else {
160
160
Log .d (TAG , "No value passed to push: " + newPath );
161
161
WritableMap res = Arguments .createMap ();
162
- res .putString ("result " , "success" );
162
+ res .putString ("status " , "success" );
163
163
res .putString ("ref" , newPath );
164
164
callback .invoke (null , res );
165
165
}
@@ -180,7 +180,7 @@ public void on(final String path,
180
180
}
181
181
182
182
WritableMap resp = Arguments .createMap ();
183
- resp .putString ("result " , "success" );
183
+ resp .putString ("status " , "success" );
184
184
resp .putString ("handle" , path );
185
185
callback .invoke (null , resp );
186
186
}
@@ -205,13 +205,31 @@ public void onOnce(final String path,
205
205
public void off (
206
206
final String path ,
207
207
final String modifiersString ,
208
- @ Deprecated final String name ,
208
+ final String name ,
209
209
final Callback callback ) {
210
- this .removeDBHandle (path , modifiersString );
210
+
211
+ String key = this .getDBListenerKey (path , modifiersString );
212
+ FirestackDatabaseReference r = mDBListeners .get (key );
213
+
214
+ if (r != null ) {
215
+ if (name == null || "" .equals (name )) {
216
+ r .cleanup ();
217
+ mDBListeners .remove (key );
218
+ } else {
219
+ //TODO: Remove individual listeners as per iOS code
220
+ //1) Remove event handler
221
+ //2) If no more listeners, remove from listeners map
222
+ r .cleanup ();
223
+ mDBListeners .remove (key );
224
+ }
225
+ }
226
+
211
227
Log .d (TAG , "Removed listener " + path + "/" + modifiersString );
212
228
WritableMap resp = Arguments .createMap ();
213
229
resp .putString ("handle" , path );
214
- resp .putString ("result" , "success" );
230
+ resp .putString ("status" , "success" );
231
+ resp .putString ("modifiersString" , modifiersString );
232
+ //TODO: Remaining listeners
215
233
callback .invoke (null , resp );
216
234
}
217
235
@@ -304,14 +322,4 @@ private FirestackDatabaseReference getDBHandle(final String path,
304
322
private String getDBListenerKey (String path , String modifiersString ) {
305
323
return path + " | " + modifiersString ;
306
324
}
307
-
308
- private void removeDBHandle (final String path , String modifiersString ) {
309
- String key = this .getDBListenerKey (path , modifiersString );
310
- FirestackDatabaseReference r = mDBListeners .get (key );
311
-
312
- if (r != null ) {
313
- r .cleanup ();
314
- mDBListeners .remove (key );
315
- }
316
- }
317
325
}
0 commit comments