Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.14 KB

repeatwhen.md

File metadata and controls

52 lines (35 loc) · 1.14 KB

repeatWhen

signature: repeatWhen(notifier: (notifications: Observable) => Observable): Observable

Repeat an observable on completion based on custom criteria.


💡 If you just want to repeat a specified number of times, try retry!


Ultimate RxJS

Examples

Example 1: Repeat on interval

( StackBlitz )

// RxJS v6+
import { of, interval } from 'rxjs';
import { repeatWhen, take } from 'rxjs/operators';

const repeatInterval$ = interval(1000).pipe(take(5));
const source$ = of('hey!').pipe(repeatWhen(_ => repeatInterval$));

source$.subscribe(console.log);

/*
OUTPUT:
hey!
hey!
hey!
hey!
hey!
hey!
*/

Additional Resources


📁 Source Code: https://github.com/ReactiveX/rxjs/blob/6.5.2/src/internal/operators/repeatWhen.ts