https://kotlinlang.org logo
#rx
Title
# rx
u

ursus

11/04/2020, 11:49 PM
(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

StavFX

11/06/2020, 7:58 PM
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

ursus

11/09/2020, 5:56 PM
smart
4 Views