Skip to content

Commit 7cf59cd

Browse files
authored
Merge pull request #35 from m7mdyahia/master
observeSingleValueEvent call onSuccess only when data exists
2 parents a2d4e07 + 16dbd5c commit 7cf59cd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/src/main/java/durdinapps/rxfirebase2/RxFirebaseDatabase.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void cancel() throws Exception {
8282
*
8383
* @param query reference represents a particular location in your Database and can be used for reading or writing data to that Database location.
8484
* @return a {@link Maybe} which emits the actual state of the database for the given query. onSuccess will be only call when
85-
* the given {@link DataSnapshot} exists.
85+
* the given {@link DataSnapshot} exists onComplete will only called when the data doesn't exist.
8686
*/
8787
@NonNull
8888
public static Maybe<DataSnapshot> observeSingleValueEvent(@NonNull final Query query) {
@@ -95,7 +95,9 @@ public void onDataChange(DataSnapshot dataSnapshot) {
9595
if (dataSnapshot.exists()) {
9696
emitter.onSuccess(dataSnapshot);
9797
}
98-
emitter.onComplete();
98+
else {
99+
emitter.onComplete();
100+
}
99101
}
100102

101103
@Override

0 commit comments

Comments
 (0)