60 lines
2.4 KiB
JavaScript
60 lines
2.4 KiB
JavaScript
"use strict";
|
|
var __extends = (this && this.__extends) || function (d, b) {
|
|
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var Subscriber_1 = require('../Subscriber');
|
|
var Notification_1 = require('../Notification');
|
|
function observeOn(scheduler, delay) {
|
|
if (delay === void 0) { delay = 0; }
|
|
return this.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) {
|
|
return 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; }
|
|
_super.call(this, destination);
|
|
this.scheduler = scheduler;
|
|
this.delay = delay;
|
|
}
|
|
ObserveOnSubscriber.dispatch = function (_a) {
|
|
var notification = _a.notification, destination = _a.destination;
|
|
notification.observe(destination);
|
|
};
|
|
ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
|
|
this.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));
|
|
};
|
|
ObserveOnSubscriber.prototype._complete = function () {
|
|
this.scheduleMessage(Notification_1.Notification.createComplete());
|
|
};
|
|
return ObserveOnSubscriber;
|
|
}(Subscriber_1.Subscriber));
|
|
exports.ObserveOnSubscriber = ObserveOnSubscriber;
|
|
var ObserveOnMessage = (function () {
|
|
function ObserveOnMessage(notification, destination) {
|
|
this.notification = notification;
|
|
this.destination = destination;
|
|
}
|
|
return ObserveOnMessage;
|
|
}());
|
|
//# sourceMappingURL=observeOn.js.map
|