takeWhile(predicate)
will emit values from source while they satisfy given predicate, and will complete once emitted value dissatisfies the predicate:
123456789101112const { rxObserver } = require('api/v0.3'); const { timer } = require('rxjs'); const { takeWhile } = require('rxjs/operators'); const source$ = timer(0, 100); source$.subscribe(rxObserver('source$')); source$.pipe( takeWhile(n => n < 5) ) .subscribe(rxObserver('takeWhile(n < 5)'));
⚠️ Execution time is limited to 1000ms