Switch

There could be complex scenarios wherein we should be able to automatically unsubscribe from an Observable to subscribe to a new one in a continuous subscribe-unsubscribe sequence.

RxJava's switch(), as per the definition, transforms an Observable emitting Observables into an Observable emitting the most recent emitted Observable.

Given a source Observable that emits a sequence of Observables, switch() subscribes to the source Observable and starts emitting the same items emitted by the first emitted Observable. When the source emits a new Observable, switch() immediately unsubscribes from the old Observable (thus interrupting the item flow from it) and subscribes to the new one, starting to emit its items.

Switch
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.34.226