Operator onBackpressureLatest()

This operator works exactly the same as the BackpressureStrategy.LATEST-it drops all the emissions keeping the latest one when the downstream is busy and can't keep up. When the downstream finishes the previous operation, it'll get the last emission just before it finished. Unfortunately, this doesn't provide any configurations; you will probably not need it.

Let's take a look at this code example:

 fun main(args: Array<String>) { val source = Observable.range(1, 1000) source.toFlowable(BackpressureStrategy.MISSING)//(1) .onBackpressureLatest()//(2) .map { MyItem13(it) } .observeOn(Schedulers.io()) .subscribe{ print("-> $it;\t") runBlocking { delay(100) } } runBlocking { delay(600000) } } data class MyItem13 ...

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.