-
Notifications
You must be signed in to change notification settings - Fork 8
forkJoin
richard.szalay edited this page May 15, 2011
·
9 revisions
Subscribes to multiple source sequences and emits an array of the last value of sequence after all have completed
static function forkJoin(sources : Array.<IObservable>) : IObservable.<Array>
If any sequence completes with no value, the sequence will complete but no values will be emitted.
The returned sequence completes when the all the sequences in sources complete.
The returned sequence raises an error if any of the sequences raises an error.
ws, xs, ys = sources
zs = output
ws ──o──o──o─/
│
xs ─────o──│─o───/
│ └───┤
ys ──o─/ └─────┤
└───────────┤
│
zs ──────────────o/
ws ──o──o──o─/
xs ─────o──────x
│
ys ──o─/ │
│
zs ────────────x</pre>
IObservable.<Array>
Observable.forkJoin([
Observable.interval(500).take(2),
Observable.range(1, 10000, Scheduler.asynchronous)
])
.subscribe(
function(values : Array) : void { trace(values.join(", ")); },
function():void { trace("Completed"); }
);
// Trace output is:
// 1, 10000 (after 1 second or the count to 10000 completes, whichever completes last)
// Completed