UNPKG

@rifo/rxjs-polling

Version:
28 lines (23 loc) 1.33 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators')) : typeof define === 'function' && define.amd ? define('@rifo/rxjs-polling', ['exports', 'rxjs', 'rxjs/operators'], factory) : (global = global || self, factory((global.rifo = global.rifo || {}, global.rifo['rxjs-polling'] = {}), global.rxjs, global.rxjs.operators)); }(this, (function (exports, rxjs, operators) { 'use strict'; /** * 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 rxjs.BehaviorSubject({}); var rePolling$ = rxjs.of('').pipe(operators.delay(delayMs), operators.tap(function () { return polling$.next({}); }), operators.skip(1)); var httpPolling$ = rxjs.concat(httpRequest$, rePolling$); return polling$.pipe(operators.switchMap(function () { return httpPolling$; })); } exports.pollingOnResolved = pollingOnResolved; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=rifo-rxjs-polling.umd.js.map