Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | /** PURE_IMPORTS_START _Observable,_scheduler_async,_util_isNumeric PURE_IMPORTS_END */
|
---|
2 | import { Observable } from '../Observable';
|
---|
3 | import { async } from '../scheduler/async';
|
---|
4 | import { isNumeric } from '../util/isNumeric';
|
---|
5 | export function interval(period, scheduler) {
|
---|
6 | if (period === void 0) {
|
---|
7 | period = 0;
|
---|
8 | }
|
---|
9 | if (scheduler === void 0) {
|
---|
10 | scheduler = async;
|
---|
11 | }
|
---|
12 | if (!isNumeric(period) || period < 0) {
|
---|
13 | period = 0;
|
---|
14 | }
|
---|
15 | if (!scheduler || typeof scheduler.schedule !== 'function') {
|
---|
16 | scheduler = async;
|
---|
17 | }
|
---|
18 | return new Observable(function (subscriber) {
|
---|
19 | subscriber.add(scheduler.schedule(dispatch, period, { subscriber: subscriber, counter: 0, period: period }));
|
---|
20 | return subscriber;
|
---|
21 | });
|
---|
22 | }
|
---|
23 | function dispatch(state) {
|
---|
24 | var subscriber = state.subscriber, counter = state.counter, period = state.period;
|
---|
25 | subscriber.next(counter);
|
---|
26 | this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
|
---|
27 | }
|
---|
28 | //# sourceMappingURL=interval.js.map
|
---|
Note:
See
TracBrowser
for help on using the repository browser.