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

Converts a sequence of raix.reactive..Notification objects back into a stream of values.

function dematerialize() : IObservable.<*>

Remarks

The source stream may have been generated by a call to materialize or it may be generated manually.

The returned sequence completed if a Notification value of kind NotificationKind.ON_COMPLETED is received.

The returned sequence errors if a Notification value of kind NotificationKind.ON_ERROR is received.

Marble Diagrams

(o,x,/) = Instances of Notification (next, error, complete)

       (o)   (o)   (o)  (/)
xs    ──o─────o─────o────o/
        │     │     │    │
        │     │     │    │
ys    ──o─────o─────o────/

       (o)   (o)   (o)  (x)
xs    ──o─────o─────o────o/
        │     │     │    │
        │     │     │    │
ys    ──o─────o─────o────x

Return Value

IObservable.<*>

Examples

Observable.fromArray([
        new OnNext(1),
        new OnNext(2),
        new OnNext(3),
        new OnCompleted()
    ])
    .dematerialize()
    .subscribe(
        function(v : int) : void { trace(i.toString()); },
        function() : void { trace("Completed"); },
        function(e : Error ) : void { trace("Error - " + e.message); }
    );

    // Trace output is:
    // 1
    // 2
    // 3
    // Completed
Observable.fromArray([
        new OnNext(1),
        new OnNext(2),
        new OnNext(3),
        new OnError(new Error("boo"))
    ])
    .dematerialize()
    .subscribe(
        function(v : int) : void { trace(i.toString()); },
        function() : void { trace("Completed"); },
        function(e : Error ) : void { trace("Error - " + e.message); }
    );

    // Trace output is:
    // 1
    // 2
    // 3
    // Error - boo
Clone this wiki locally