takeUntil - richardszalay/raix GitHub Wiki
ο»ΏTakes values from a source sequence until a value is received from another sequence
function takeUntil(other : IObservable.<*>) : IObservable.<T>other is also subscribed to. The values in the source sequence are emitted until other emits a value, at which time other is unsubscribed from and the sequence completes.
The returned sequence completes when the source sequence completes or when other emits a value.
The returned sequence errors when the source sequence errors or when the other sequence errors.
xs = source
ys = output
other ββββββββββo
xs ββoββoββoββ
β β β β
β β β β
β β β β
ys ββoββoββoβ/
other ββββββββββββββββββ
xs ββoββoββoββoββoββ/
β β β β β β
β β β β β β
β β β β β β
ys ββoββoββoββoββoββ/IObservable.<T>
var source : IObservable = Observable.interval(500)
.takeUntil( Observable.interval(2001) );
source.subscribe(
function(value : int) : void { trace(value); },
function() : void { trace("Completed!"); }
);
// Trace output is:
// 0 (at 500 ms)
// 1 (at 1000 ms)
// 2 (at 1500 ms)
// 3 (at 2000 ms)
// Completed!