1 | /** PURE_IMPORTS_START tslib,_Subscriber,_Notification PURE_IMPORTS_END */
|
---|
2 | import * as tslib_1 from "tslib";
|
---|
3 | import { Subscriber } from '../Subscriber';
|
---|
4 | import { Notification } from '../Notification';
|
---|
5 | export function observeOn(scheduler, delay) {
|
---|
6 | if (delay === void 0) {
|
---|
7 | delay = 0;
|
---|
8 | }
|
---|
9 | return function observeOnOperatorFunction(source) {
|
---|
10 | return source.lift(new ObserveOnOperator(scheduler, delay));
|
---|
11 | };
|
---|
12 | }
|
---|
13 | var ObserveOnOperator = /*@__PURE__*/ (function () {
|
---|
14 | function ObserveOnOperator(scheduler, delay) {
|
---|
15 | if (delay === void 0) {
|
---|
16 | delay = 0;
|
---|
17 | }
|
---|
18 | this.scheduler = scheduler;
|
---|
19 | this.delay = delay;
|
---|
20 | }
|
---|
21 | ObserveOnOperator.prototype.call = function (subscriber, source) {
|
---|
22 | return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
|
---|
23 | };
|
---|
24 | return ObserveOnOperator;
|
---|
25 | }());
|
---|
26 | export { ObserveOnOperator };
|
---|
27 | var ObserveOnSubscriber = /*@__PURE__*/ (function (_super) {
|
---|
28 | tslib_1.__extends(ObserveOnSubscriber, _super);
|
---|
29 | function ObserveOnSubscriber(destination, scheduler, delay) {
|
---|
30 | if (delay === void 0) {
|
---|
31 | delay = 0;
|
---|
32 | }
|
---|
33 | var _this = _super.call(this, destination) || this;
|
---|
34 | _this.scheduler = scheduler;
|
---|
35 | _this.delay = delay;
|
---|
36 | return _this;
|
---|
37 | }
|
---|
38 | ObserveOnSubscriber.dispatch = function (arg) {
|
---|
39 | var notification = arg.notification, destination = arg.destination;
|
---|
40 | notification.observe(destination);
|
---|
41 | this.unsubscribe();
|
---|
42 | };
|
---|
43 | ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
|
---|
44 | var destination = this.destination;
|
---|
45 | destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
|
---|
46 | };
|
---|
47 | ObserveOnSubscriber.prototype._next = function (value) {
|
---|
48 | this.scheduleMessage(Notification.createNext(value));
|
---|
49 | };
|
---|
50 | ObserveOnSubscriber.prototype._error = function (err) {
|
---|
51 | this.scheduleMessage(Notification.createError(err));
|
---|
52 | this.unsubscribe();
|
---|
53 | };
|
---|
54 | ObserveOnSubscriber.prototype._complete = function () {
|
---|
55 | this.scheduleMessage(Notification.createComplete());
|
---|
56 | this.unsubscribe();
|
---|
57 | };
|
---|
58 | return ObserveOnSubscriber;
|
---|
59 | }(Subscriber));
|
---|
60 | export { ObserveOnSubscriber };
|
---|
61 | var ObserveOnMessage = /*@__PURE__*/ (function () {
|
---|
62 | function ObserveOnMessage(notification, destination) {
|
---|
63 | this.notification = notification;
|
---|
64 | this.destination = destination;
|
---|
65 | }
|
---|
66 | return ObserveOnMessage;
|
---|
67 | }());
|
---|
68 | export { ObserveOnMessage };
|
---|
69 | //# sourceMappingURL=observeOn.js.map
|
---|