(its basically -- reading from cache if possible, ...
# rx
u
(its basically -- reading from cache if possible, else fetching from network I wanna show a progressbar in both cases, however when its a cache hit, the emit comes too fast and progressbar just "blinks" and is bad UX )
s
Copy code
Observable.combineLatest(
   source, Observable.timer(minProgressTimeMs, TimeUnit.MILLISECONDS)
) { data, _ -> data }
That way any "data" coming from
source
would wait until the first (and only) emission from
timer
before continuing downstream. Also, this has the added benefit of only showing the network-data, in the case that
source
emits it faster than
minProgressTimeMs
. So you won't get a "flash" of cache-data, quickly followed by network-data
u
smart