timing-provider
Version:
An implementation of the timing provider specification.
6 lines • 601 B
JavaScript
import { EMPTY, endWith, ignoreElements, interval, map, startWith, switchAll, tap, withLatestFrom } from 'rxjs';
export const sendPeriodicPings = (localSentTimesSubject, now) => (source) => source.pipe(map(([, send]) => interval(1000).pipe(startWith(0), map((_, index) => {
send({ index, type: 'ping' });
return now();
}), withLatestFrom(localSentTimesSubject), tap(([localSentTime, [startIndex, localSentTimes]]) => localSentTimesSubject.next([startIndex, [...localSentTimes, localSentTime]])), ignoreElements())), endWith(EMPTY), switchAll());
//# sourceMappingURL=send-periodic-pings.js.map