@rifo/rxjs-polling
Version:
RxJS HTTP Polling
28 lines (23 loc) • 768 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 = 0) {
const polling$ = new BehaviorSubject({});
const rePolling$ = of('').pipe(delay(delayMs), tap(() => polling$.next({})), skip(1));
const httpPolling$ = concat(httpRequest$, rePolling$);
return polling$.pipe(switchMap(() => httpPolling$));
}
/*
* Public API Surface of rxjs-polling
*/
/**
* Generated bundle index. Do not edit.
*/
export { pollingOnResolved };
//# sourceMappingURL=rifo-rxjs-polling.js.map