@rifo/rxjs-polling
Version:
RxJS HTTP Polling
29 lines (24 loc) • 839 B
JavaScript
import { BehaviorSubject, of, concat } from 'rxjs';
import { delay, tap, skip, switchMap } from 'rxjs/operators';
/**
* Polling when data is resolved
* @param httpRequest$ any http request.
* @param delayMs delay in ms
*
* Inspire by https://blog.strongbrew.io/rxjs-polling/
*/
function pollingOnResolved(httpRequest$, delayMs) {
if (delayMs === void 0) { delayMs = 0; }
var polling$ = new BehaviorSubject({});
var rePolling$ = of('').pipe(delay(delayMs), tap(function () { return polling$.next({}); }), skip(1));
var httpPolling$ = concat(httpRequest$, rePolling$);
return polling$.pipe(switchMap(function () { return httpPolling$; }));
}
/*
* Public API Surface of rxjs-polling
*/
/**
* Generated bundle index. Do not edit.
*/
export { pollingOnResolved };
//# sourceMappingURL=rifo-rxjs-polling.js.map