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

Emits a set number or values from the start of the source sequence before completing.

function take(count : uint) : IObservable.<T>

Remarks

The returned sequence completes when the source sequence completes or when count values have been emitted.

The returned sequence errors when the source sequences errors

Marble Diagrams

x = count

xs  ──o──o─────o
      1  2 ... n
      │  │     │
ys  ──o──o─────o/

Return Value

IObservable.<T>

Examples

Observable.range(0, 5)
    .take(3)
    .subscribe(function(value : int) : void
    {
        trace(value);
    });

    // Trace output is:
    // 0
    // 1
    // 2