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

Emits the last value from a source sequence or throws an error if the sequence is empty.

function last() : IObservable.<T>

Remarks

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

Marble Diagrams

xs = source
ys = output

xs  ──o───o─o────o──/
                 │
                 └──┐
                    │
ys  ────────────────o/


xs  ────────────────/
                    │
                    │
                    │
ys  ────────────────x

Return Value

IObservable.<T>

Examples

var source : IObservable = Observable.range(0, 5)
    .last();

source.subscribe(
    function(value : int) : void { trace(value; },
    function() : void { trace("Completed!"); }
    );

// Trace output is:
// 4
// Completed!
Clone this wiki locally