The BlockingObservable class
Every Observable
instance can be turned into a BlockingObservable
instance with the toBlocking()
method. The BlockingObservable
instance has multiple methods that block the current thread, while everything is emitted by the source Observable
instance until an OnCompleted
or OnError
notification is sent. If there is an OnError
notification, an exception will be thrown (RuntimeException
exceptions are thrown directly and checked exceptions are wrapped inside the RuntimeException
instances).
The toBlocking()
method doesn't block by itself, but the methods of the BlockingObservable
instance it returns may block. Let's look at some of those methods:
- We can iterate over all the items in the
BlockingObservable
instance, using ...
Get Learning Reactive Programming with Java 8 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.