source: trip-planner-front/node_modules/rxjs/_esm2015/internal/observable/timer.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import { Observable } from '../Observable';
2import { async } from '../scheduler/async';
3import { isNumeric } from '../util/isNumeric';
4import { isScheduler } from '../util/isScheduler';
5export function timer(dueTime = 0, periodOrScheduler, scheduler) {
6 let period = -1;
7 if (isNumeric(periodOrScheduler)) {
8 period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
9 }
10 else if (isScheduler(periodOrScheduler)) {
11 scheduler = periodOrScheduler;
12 }
13 if (!isScheduler(scheduler)) {
14 scheduler = async;
15 }
16 return new Observable(subscriber => {
17 const due = isNumeric(dueTime)
18 ? dueTime
19 : (+dueTime - scheduler.now());
20 return scheduler.schedule(dispatch, due, {
21 index: 0, period, subscriber
22 });
23 });
24}
25function dispatch(state) {
26 const { index, period, subscriber } = state;
27 subscriber.next(index);
28 if (subscriber.closed) {
29 return;
30 }
31 else if (period === -1) {
32 return subscriber.complete();
33 }
34 state.index = index + 1;
35 this.schedule(state, period);
36}
37//# sourceMappingURL=timer.js.map
Note: See TracBrowser for help on using the repository browser.