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

Creates a sequence of type that emits the values in values then completes. Passing an array to the toObservable global function has a shorthand way of calling this method.

static function fromArray(values : Array.<T>, 
    scheduler : IScheduler = null) : IObservable.<T>

Remarks

The returned sequence completes after emitting the last value in values

The returned sequence does not error

Marble Diagrams

────o────────────o────────────────o───────/
 values[0]    values[1]  ...  values[n─1]

Scheduling

Unless specified, this operator uses Scheduler.defaultScheduler.

Return Value

IObservable.<T>

Examples

Observable.fromArray([5, 4, 3, 2, 1])
    .subscribe(
        function(value:int) : void { trace(value); },
        function():void { trace("Completed!"); }
     );

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