-
Notifications
You must be signed in to change notification settings - Fork 8
observeOn
richardszalay edited this page May 20, 2011
·
6 revisions
Defers messages to subscribers through a scheduler
function observeOn(scheduler : IScheduler) : IObservable.<T>
observeOn should only be used when the scheduler must be changed and the source operator does not accept a custom scheduler.
The returned sequence completes if the source sequence completes
The returned sequence errors if the source sequence errors
sch = scheduler
xs ──o─────o─────/
│ │ │
sch --└─┐---└─┐---└─┐
│ │ │
zs ────o─────o─────/
IObservable.<T>
var subject : Subject = new Subject();
subject.observeOn(Scheduler.asynchronous)
.subscribe(
function(x:int) : void { trace(x); },
function() : void { trace("Completed"); }
);
subject.onNext(1);
subject.onNext(2);
subject.onNext(3);
// Trace output is:
// (Sometime in the future)
// 1
// 2
// 3
// Completed