UNPKG

706 BPlain TextView Raw
1
2import { Observable } from 'rxjs';
3import { repeat as higherOrder } from 'rxjs/operators';
4
5/**
6 * Returns an Observable that repeats the stream of items emitted by the source Observable at most count times.
7 *
8 * <img src="./img/repeat.png" width="100%">
9 *
10 * @param {number} [count] The number of times the source Observable items are repeated, a count of 0 will yield
11 * an empty Observable.
12 * @return {Observable} An Observable that repeats the stream of items emitted by the source Observable at most
13 * count times.
14 * @method repeat
15 * @owner Observable
16 */
17export function repeat<T>(this: Observable<T>, count: number = -1): Observable<T> {
18 return higherOrder(count)(this) as Observable<T>;
19}