Skip to content
richardszalay edited this page May 20, 2011 · 6 revisions

Defers messages to subscribers through a scheduler

function observeOn(scheduler : IScheduler) : IObservable.<T>

Remarks

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

Marble Diagrams

sch = scheduler

xs  ──o─────o─────/
      │     │     │
sch --└─┐---└─┐---└─┐
        │     │     │
zs  ────o─────o─────/

Return Value

IObservable.<T>

Examples

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
Clone this wiki locally