December 2017
Intermediate to advanced
322 pages
7h 3m
English
Like onBackpressureBuffer matches with BackpressureStrategy.BUFFER, onBackpressureDrop matches with BackpressureStrategy.DROP in terms of backpressure strategy, with some configuration options.
So, let's now try this:
fun main(args: Array<String>) {
val source = Observable.range(1, 1000)
source.toFlowable(BackpressureStrategy.MISSING)//(1)
.onBackpressureDrop{ print("Dropped $it;\t") }//(2)
.map { MyItem12(it) }
.observeOn(Schedulers.io())
.subscribe{
print("Rec. $it;\t")
runBlocking { delay(1000) }
}
runBlocking { delay(600000) }
}
data class MyItem12 (val id:Int) {
init {
print("MyItem init $id;\t")
}
}
As shown in the previous program, we used BackpressureStrategy.MISSING on comment (1). On comment (2)
Read now
Unlock full access