Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | import { Observable } from '../Observable';
|
---|
2 | import { asap } from '../scheduler/asap';
|
---|
3 | import { isNumeric } from '../util/isNumeric';
|
---|
4 | export class SubscribeOnObservable extends Observable {
|
---|
5 | constructor(source, delayTime = 0, scheduler = asap) {
|
---|
6 | super();
|
---|
7 | this.source = source;
|
---|
8 | this.delayTime = delayTime;
|
---|
9 | this.scheduler = scheduler;
|
---|
10 | if (!isNumeric(delayTime) || delayTime < 0) {
|
---|
11 | this.delayTime = 0;
|
---|
12 | }
|
---|
13 | if (!scheduler || typeof scheduler.schedule !== 'function') {
|
---|
14 | this.scheduler = asap;
|
---|
15 | }
|
---|
16 | }
|
---|
17 | static create(source, delay = 0, scheduler = asap) {
|
---|
18 | return new SubscribeOnObservable(source, delay, scheduler);
|
---|
19 | }
|
---|
20 | static dispatch(arg) {
|
---|
21 | const { source, subscriber } = arg;
|
---|
22 | return this.add(source.subscribe(subscriber));
|
---|
23 | }
|
---|
24 | _subscribe(subscriber) {
|
---|
25 | const delay = this.delayTime;
|
---|
26 | const source = this.source;
|
---|
27 | const scheduler = this.scheduler;
|
---|
28 | return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
|
---|
29 | source, subscriber
|
---|
30 | });
|
---|
31 | }
|
---|
32 | }
|
---|
33 | //# sourceMappingURL=SubscribeOnObservable.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.