I am using an android library FrangSierra for listening to Firebase
database events. This library returns RxJava2
Flowables
to work with. I show a loading dialog when I start loading data and need to hide it when data is received. Now the problem is when there is no data and I need to show an empty view because Flowable
never calls OnComplete
.
I tried applying timeout
and the problem is it will probably always timeout after data is finished loading. I also want to keep subscription for future events. My question is how do I detect 0 records scenario here.
You can use switchIfEmpty
operator:
Flowable.just(1)
.filter(value -> (value != 1))
.switchIfEmpty(Completable.fromRunnable(() -> System.out.println("Empty stream")).toFlowable())
.subscribe();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.