Imagine a pipe of subscribers that you emit event to and it visits one subscriber after another.
Having a PublishSubject and x subscribers/observables. Normally events are emitted to observers in a specific order but simultaneously regardless of when observers return. Is it possible to do this flow :
- emit event to observerA
- after osbserverA returns, emit the event to observerB
- after observerB returns, emit the event to observerC
I'm using RxScala and Monifu Rx implementations
Monifu even has a back-pressure implementation :
def onNext(elem: T): Future[Ack]
I'd like to see "And Result was : Changed !!" be printed out in this sample:
val subject = PublishSubject[Int]()
var result = "Not Changed"
subject.subscribe { i =>
Observable.timerOneTime(3.seconds, Continue).asFuture.map { x =>
result = "Changed !!"
x.get
}
}
subject.subscribe { i =>
Observable.timerOneTime(1.seconds, Continue).asFuture.map { x =>
println("And Result was : " + result)
x.get
}
}
subject.onNext(1)
Is it possible in RxScala/RxJava or Monifu without extending Subject and overriding onNext implementation? These classes are declared final anyway so it would be rather hacking.