skip to content

takeUntil

 

takeUntil(otherStream) will complete when another (terminating) stream emits a value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const { rxObserver } = require('api/v0.3');
const { timer } = require('rxjs');
const { takeUntil } = require('rxjs/operators');

const source$ = timer(0, 100);
const terminator$ = timer(550);

source$.subscribe(rxObserver('source$'));
terminator$.subscribe(rxObserver('terminator$'));
source$.pipe(
    takeUntil(terminator$)
  )
  .subscribe(rxObserver('takeUntil'));
⚠️ Execution time is limited to 1000ms
0mssource$start00 11 22 33 44 55 66 77 88 99 1010 terminator$startcomplete00 takeUntilstartcomplete00 11 22 33 44 55

Also see take and takeUntil operators