Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxJava timeout without emiting error?

Is there an option to have variant of timeout that does not emit Throwable?

I would like to have complete event emited.

like image 929
pixel Avatar asked Jul 04 '16 08:07

pixel


People also ask

What is RX timeout?

When first configuring (or on occasion after setup is complete), you may see an error indicating “RX Timeout!” when sending a command or poll to the Serial MODBUS Gateway. This indicates there is a communication error and is generally a result of a configuration or wiring issue.

Is RxJava blocking?

Usually, asynchronous code is non-blocking: You call a method that returns immediately, allowing your code to continue its execution. Once the result of your call is available, it is returned via a callback. RxJava is asynchronous, too. And it is blocking as well — at least by default.


1 Answers

You don't need to map errors with onErrorResumeNext. You can just provide a backup observable using:

timeout(long,TimeUnit,Observable)

It would be something like:

    .timeout(500, TimeUnit.MILLISECONDS, Observable.empty())
like image 117
X.Y. Avatar answered Sep 25 '22 01:09

X.Y.