observeOn.js
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Subscriber } from '../Subscriber';
import { Notification } from '../Notification';
export function observeOn(scheduler, delay = 0) {
return function observeOnOperatorFunction(source) {
return source.lift(new ObserveOnOperator(scheduler, delay));
};
}
export class ObserveOnOperator {
constructor(scheduler, delay = 0) {
this.scheduler = scheduler;
this.delay = delay;
}
call(subscriber, source) {
return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
}
}
export class ObserveOnSubscriber extends Subscriber {
constructor(destination, scheduler, delay = 0) {
super(destination);
this.scheduler = scheduler;
this.delay = delay;
}
static dispatch(arg) {
const { notification, destination } = arg;
notification.observe(destination);
this.unsubscribe();
}
scheduleMessage(notification) {
const destination = this.destination;
destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
}
_next(value) {
this.scheduleMessage(Notification.createNext(value));
}
_error(err) {
this.scheduleMessage(Notification.createError(err));
this.unsubscribe();
}
_complete() {
this.scheduleMessage(Notification.createComplete());
this.unsubscribe();
}
}
export class ObserveOnMessage {
constructor(notification, destination) {
this.notification = notification;
this.destination = destination;
}
}
//# sourceMappingURL=observeOn.js.map