repeat

signature: repeat(count: number): Observable

Repeats an observable on completion.


:bulb: Like retry but for non error cases!


Examples

Example 1: Repeat 3 times

( StackBlitz )

// RxJS v6+
import { repeat, delay } from 'rxjs/operators';
import { of } from 'rxjs';

const delayedThing = of('delayed value').pipe(delay(2000));

delayedThing.pipe(
  repeat(3)
)
// delayed value...delayed value...delayed value
.subscribe(console.log)

Additional Resources


:file_folder: Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/repeat.ts

results matching ""

    No results matching ""