frontend/.pnpm-store/v3/files/55/d6ca9f47d55c86ba194a6cfbb5c15f3d58c431fa123e69e35c0cd592c952b82978ddd9580bea8220f36ccea5f245261f6832460156fab9caa179c7787bc019

21 lines
758 B
Plaintext

import { Observable } from '../Observable';
import { async } from '../scheduler/async';
import { isNumeric } from '../util/isNumeric';
export function interval(period = 0, scheduler = async) {
if (!isNumeric(period) || period < 0) {
period = 0;
}
if (!scheduler || typeof scheduler.schedule !== 'function') {
scheduler = async;
}
return new Observable(subscriber => {
subscriber.add(scheduler.schedule(dispatch, period, { subscriber, counter: 0, period }));
return subscriber;
});
}
function dispatch(state) {
const { subscriber, counter, period } = state;
subscriber.next(counter);
this.schedule({ subscriber, counter: counter + 1, period }, period);
}
//# sourceMappingURL=interval.js.map