takeWhile
RxJS 5 takeWhile
HTML
<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>
JavaScript
// emit 3, 3, 3, 9, 1, 4, 5, 8, 96, 3, 66, 3, 3, 3
const source = Rx.Observable.of(3, 3, 3, 9, 1, 4, 5, 8, 96, 3, 66, 3, 3, 3);
// allow values until value from source equals 3, then complete
// output: [3, 3, 3]
source
.takeWhile(it => it === 3 )
.subscribe(val => console.log('takeWhile', val));
// output: [3, 3, 3, 3, 3, 3, 3]
source
.filter(it => it === 3)
.subscribe(val => console.log('filter', val));