FrangSierra/RxFirebase

calling both on onSuccess() and onComplete() breaks MaybeObserver contract

m7mdyahia opened this issue · 1 comments

https://github.com/FrangSierra/Rx2Firebase/blob/a2d4e07d5d68e541c847892f160f263cd18a1388/app/src/main/java/durdinapps/rxfirebase2/RxFirebaseDatabase.java#L94-L99

as stated in MaybeObserver contract
After a MaybeObserver calls a Maybe's subscribe method, first the Maybe calls onSubscribe(Disposable) with a Disposable that allows cancelling the sequence at any time, then the Maybe calls only one of the MaybeObserver's onSuccess(T), onError(java.lang.Throwable) or onComplete() methods to provide notifications.

so I suggest this should be

 public void onDataChange(DataSnapshot dataSnapshot) { 
    if (dataSnapshot.exists()) { 
       emitter.onSuccess(dataSnapshot); 
    } else {
    emitter.onComplete(); 
    }
} 

Totally right, if you want feel free to upload a PR with the changes in the Maybe calls. If not, I will fix it in the next release.

Thank you so much for your feedback!