💡 If you just want to repeat a specified number of times, try retry!
( 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!
*/
- repeatWhen 📰 - Official docs
📁 Source Code: https://github.com/ReactiveX/rxjs/blob/6.5.2/src/internal/operators/repeatWhen.ts