The onErrorResumeNext operator

The onErrorResumeNext operator helps you subscribe to a different producer in case any error occurs.

Here is an example:

    fun main(args: Array<String>) { 
      Observable.just(1,2,3,4,5) 
        .map { it/(3-it) } 
        .onErrorResumeNext(Observable.range(10,5))//(1) 
        .subscribe { 
           println("Received $it") 
        } 
   }

The output is as follows:

This operator is especially useful when you want to subscribe to another source producer in case any error occurs.

Get Reactive Programming in Kotlin 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.