The ignoreElements operator

Sometimes, you may require to listen only on the onComplete of a producer. The ignoreElements operator helps you to do that. Please refer to the following code:

    fun main(args: Array<String>) { 
      val observable = Observable.range(1,10) 
      observable 
        .ignoreElements() 
        .subscribe { println("Completed") }//(1) 
    } 

The ignoreElements operator returns a Completable monad, which only has the onComplete event.

We will look into the skip and take operators in Chapter 6More on Operators and Error Handling while discussing conditional operators.

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.