1
votes

I have a rxjava observable chain with a set of operators. Let's say I have the source Observable (emitting items always every minute), operator B that performs a network request, and timeout operator. I want the timeout operator only take into account items emitted from the operator B, but ignore those emitted by the source Observable. What I want is to end the subscription if in one hore, no items have been emitted from the operator B, as the server is down, for example, and no results are emmited to the subscriber.

Example:

Observable.timer(1, TimeUnit.SECONDS)
   .flatMap { performNetworkRequest() }
   .timeout(1, TimeUnit.HOUR)

So my idea is to end this timer after one hour with no server responses. But timeout operator does not work that way, as it is reseted one the timer observable emmits a new item every minute.

1

1 Answers

0
votes

This is what Doc says

The Timeout operator allows you to abort an Observable with an onError termination if that Observable fails to emit any items during a specified span of time.

-Here you are emitting item every minute so its not working like you want.