Closed bnvinay92 closed 8 years ago
Since this library aims to wrap Firebase Android SDK into Rx, custom behavior (like ChildReadyEvent
) will not be added.
Instead, I can add a support for Query
to methods in RxFirebaseDatabase
.
After then, you can use it as follows:
Query query = ...;
//TODO: Show progress while Firebase loads data
RxFirebaseDatabase.data(query)
.observeOn(AndroidSchedulers.mainThread()) // For Android
.doOnError { /* TODO: Hide progress */ }
.doOnCompleted { /* TODO: Hide progress */ }
.subscribe()
@bnvinay92 I have found following method in SDK, Query.getRef()
With this method, I expect you can achieve what you want with current library by implementing as following:
Query query = ...;
//TODO: Show progress while Firebase loads data
RxFirebaseDatabase.data(query.getRef())
.observeOn(AndroidSchedulers.mainThread()) // For Android
.doOnError { /* TODO: Hide progress */ }
.doOnCompleted { /* TODO: Hide progress */ }
.subscribe()
It's tough to show empty states and handle other ui logic when you use Firebase's ChildEventListener as is. I like to add a value event listener which fires after all your current data has been loaded. Something like this:
Firebase's internal optimisation makes sure that the data on your reference only comes through the wire once.