-
Notifications
You must be signed in to change notification settings - Fork 8
first
richardszalay edited this page May 20, 2011
·
9 revisions
Emits the first value from a source sequence or throws an error when the sequence is empty.
function first() : IObservable.<T>
The returned sequence completes when the source sequence completes with values.
The returned sequence errors when the source sequences errors or if the source sequence completes without any values
xs = source
ys = output
xs ──o
│
│
│
│
ys ──o/
xs ──────/
│
│
│
│
ys ──────x
IObservable.<T>
var source : IObservable = Observable.range(0, 5)
.first();
source.subscribe(
function(value : int) : void { trace(value; },
function() : void { trace("Completed!"); }
);
// Trace output is:
// 0
// Completed!