source: trip-planner-front/node_modules/rxjs/internal/observable/timer.js@ fa375fe

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

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var Observable_1 = require("../Observable");
4var async_1 = require("../scheduler/async");
5var isNumeric_1 = require("../util/isNumeric");
6var isScheduler_1 = require("../util/isScheduler");
7function timer(dueTime, periodOrScheduler, scheduler) {
8 if (dueTime === void 0) { dueTime = 0; }
9 var period = -1;
10 if (isNumeric_1.isNumeric(periodOrScheduler)) {
11 period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
12 }
13 else if (isScheduler_1.isScheduler(periodOrScheduler)) {
14 scheduler = periodOrScheduler;
15 }
16 if (!isScheduler_1.isScheduler(scheduler)) {
17 scheduler = async_1.async;
18 }
19 return new Observable_1.Observable(function (subscriber) {
20 var due = isNumeric_1.isNumeric(dueTime)
21 ? dueTime
22 : (+dueTime - scheduler.now());
23 return scheduler.schedule(dispatch, due, {
24 index: 0, period: period, subscriber: subscriber
25 });
26 });
27}
28exports.timer = timer;
29function dispatch(state) {
30 var index = state.index, period = state.period, subscriber = state.subscriber;
31 subscriber.next(index);
32 if (subscriber.closed) {
33 return;
34 }
35 else if (period === -1) {
36 return subscriber.complete();
37 }
38 state.index = index + 1;
39 this.schedule(state, period);
40}
41//# sourceMappingURL=timer.js.map
Note: See TracBrowser for help on using the repository browser.