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

Ignores values from a source sequence until a condition is no longer met

function skipWhile(predicate : Function) : IObservable.<T>

predicate is function(value : T) : Boolean

Remarks

Each value emitted by the source will be sent to predicate. If predicate returns true, the value will be skipped. If predicate returns false, the value (and all those after it) will be emitted and predicate will no longer be called.

The returned sequence completes when the source sequence completes.

The returned sequence errors when the source sequences errors or when predicate throws an error.

Marble Diagrams

xs = source
zs = output
p(x) = predicate

xs  ──o─────o─────o───o──o──/
      │     │     │   │  │  │
     p(x)  p(x)  p(x) │  │  │
     true  true false │  │  │
                  │   │  │  │
zs  ──────────────o───o──o──/

Return Value

IObservable.<T>

Examples

var source : IObservable = Observable.range(0, 10)
    .skipWhile(function(v:int) : Boolean { return v < 5; });

source.subscribe(function(value : int) : void
    {
        trace(value);
    });

// Trace output is:
// 6
// 7
// 8
// 9
Clone this wiki locally