Subject that publishes only the last item observed to each Observer
that has subscribed, when the
source Observable}
completes.
Subject that publishes only the last item observed to each Observer
that has subscribed, when the
source Observable}
completes.
// observer will receive no onNext events because the subject.onCompleted() isn't called. val subject = AsyncSubject[String]() subject.subscribe(observer) subject.onNext("one") subject.onNext("two") subject.onNext("three") // observer will receive "three" as the only onNext event. val subject = AsyncSubject[String]() subject.subscribe(observer) subject.onNext("one") subject.onNext("two") subject.onNext("three") subject.onCompleted()
Subject that emits the most recent item it has observed and all subsequent observed items to each subscribed
Observer
.
Subject that emits the most recent item it has observed and all subsequent observed items to each subscribed
Observer
.
// observer will receive all events. val subject = BehaviorSubject[String]("default") subject.subscribe(observer) subject.onNext("one") subject.onNext("two") subject.onNext("three") // observer will receive the "one", "two" and "three" events, but not "zero" val subject = BehaviorSubject[String]("default") subject.onNext("zero") subject.onNext("one") subject.subscribe(observer) subject.onNext("two") subject.onNext("three") // observer will receive only onCompleted val subject = BehaviorSubject[String]("default") subject.onNext("zero") subject.onNext("one") subject.onCompleted() subject.subscribe(observer) // observer will receive only onError val subject = BehaviorSubject[String]("default") subject.onNext("zero") subject.onNext("one") subject.onError(new RuntimeException("error")) subject.subscribe(observer)
Subject that, once an Observer
has subscribed, emits all subsequently observed items to the
subscriber.
Subject that, once an Observer
has subscribed, emits all subsequently observed items to the
subscriber.
val subject = PublishSubject[String]() // observer1 will receive all onNext and onCompleted events subject.subscribe(observer1) subject.onNext("one") subject.onNext("two") // observer2 will only receive "three" and onCompleted subject.subscribe(observer2) subject.onNext("three") subject.onCompleted()
Subject that buffers all items it observes and replays them to any Observer
that subscribes.
Subject that buffers all items it observes and replays them to any Observer
that subscribes.
val subject = ReplaySubject[String]() subject.onNext("one") subject.onNext("two") subject.onNext("three") subject.onCompleted() // both of the following will get the onNext/onCompleted calls from above subject.subscribe(observer1) subject.subscribe(observer2)
Wraps a Subject to ensure that the resulting Subject is chronologically well-behaved.
Wraps a Subject to ensure that the resulting Subject is chronologically well-behaved.
A well-behaved Subject does not interleave its invocations of the onNext,
onCompleted, and onError methods of
its rx.lang.scala.Subjects; it invokes onCompleted
or onError
only once; and it never invokes onNext
after invoking either onCompleted
or onError
.
SerializedSubject enforces this, and the Subject it returns invokes onNext
and
onCompleted
or onError
synchronously on the wrapped Subject.
A variety of Subject that is useful for testing purposes.
A variety of Subject that is useful for testing purposes. It operates on a TestScheduler
and allows
you to precisely time emissions and notifications to the Subject's subscribers.
Subjects are Observers and Observables at the same time.