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

Maps values from a source sequence through a function and emits the returned values.

function map(valueClass : Class, selector : Function) : IObservable.<TResult>

Where valueClass is the output type of selector

Where selector is: function (value : sourceType) : TResult

Remarks

The returned sequence completes when the source sequence completes.

The returned sequence raises an error if the source sequence raises an error.

Marble Diagrams

s = selector

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

Return Value

IObservable.<TResult>

Examples

Observable.range(0, 5)
    .map(function(v:int) : String { return v.toString() + "!"; })
    .subscribe(
        function(value : String) : void { trace(value); },
        function():void { trace("Completed"); }
    );

    // Trace output is:
    // 0!
    // 1!
    // 2!
    // 3!
    // 4!
    // Completed
Clone this wiki locally