Processor
Processors are the counterparts for Subjects
in Flowable. Every type of Subject
has its counterpart as processor with backpressure support.
In the previous chapter (Chapter 3, Observables, Observers, and Subjects), we started exploring Subject
, with the PublishSubject
; so, let's do the same here. Let's get started with PublishProcessor
.
The following is an example of PublishProcessor
:
fun main(args: Array<String>) { val flowable = listOf("String 1","String 2","String 3", "String 4","String 5").toFlowable()//(1) val processor = PublishProcessor.create<String>()//(2) processor.//(3) subscribe({ println("Subscription 1: $it") runBlocking { delay(1000) } println("Subscription 1 delay") }) processor//(4) .subscribe({ println("Subscription 2 $it")}) flowable.subscribe(processor)//(5) }
So, in this example, on comment (1)
, we created a Flowable
with the Iterable...