What's the best way to emit items from an observab...
# rx
e
What's the best way to emit items from an observable iff another observable hasn't emitted in a certain amount of time, in which case the first observable should emit, followed by the second observable? The use case is I have a list cached that I want to emit iff a network call to get an updated list hasn't come back yet, so I want to either only emit the updated list, or emit the cached list followed by the updated list. So far I've been able to use
amb
to achieve the first part, but I can't figure out how to emit from both observables if the network one doesn't finish fast enough:
Copy code
val cachedObservable = Observable.from(...).delay(500, TimeUnit.MILLISECONDS)

val networkObservable = observable {
  val newList = getUpdatedListFromNetwork()
  if(!it.isUnsubscribed) it.onNext(newList)
}

return Observable.amb(cachedObservable, networkObservable)