You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
3.1 KiB

4 years ago
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Subscriber_1 = require("../Subscriber");
var Notification_1 = require("../Notification");
function observeOn(scheduler, delay) {
if (delay === void 0) { delay = 0; }
return function observeOnOperatorFunction(source) {
return source.lift(new ObserveOnOperator(scheduler, delay));
};
}
exports.observeOn = observeOn;
var ObserveOnOperator = (function () {
function ObserveOnOperator(scheduler, delay) {
if (delay === void 0) { delay = 0; }
this.scheduler = scheduler;
this.delay = delay;
}
ObserveOnOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
};
return ObserveOnOperator;
}());
exports.ObserveOnOperator = ObserveOnOperator;
var ObserveOnSubscriber = (function (_super) {
__extends(ObserveOnSubscriber, _super);
function ObserveOnSubscriber(destination, scheduler, delay) {
if (delay === void 0) { delay = 0; }
var _this = _super.call(this, destination) || this;
_this.scheduler = scheduler;
_this.delay = delay;
return _this;
}
ObserveOnSubscriber.dispatch = function (arg) {
var notification = arg.notification, destination = arg.destination;
notification.observe(destination);
this.unsubscribe();
};
ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
var destination = this.destination;
destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
};
ObserveOnSubscriber.prototype._next = function (value) {
this.scheduleMessage(Notification_1.Notification.createNext(value));
};
ObserveOnSubscriber.prototype._error = function (err) {
this.scheduleMessage(Notification_1.Notification.createError(err));
this.unsubscribe();
};
ObserveOnSubscriber.prototype._complete = function () {
this.scheduleMessage(Notification_1.Notification.createComplete());
this.unsubscribe();
};
return ObserveOnSubscriber;
}(Subscriber_1.Subscriber));
exports.ObserveOnSubscriber = ObserveOnSubscriber;
var ObserveOnMessage = (function () {
function ObserveOnMessage(notification, destination) {
this.notification = notification;
this.destination = destination;
}
return ObserveOnMessage;
}());
exports.ObserveOnMessage = ObserveOnMessage;
//# sourceMappingURL=observeOn.js.map