Bones/node_modules/rxjs/operator/exhaust.js

56 lines
2.2 KiB
JavaScript
Raw Normal View History

2017-05-17 13:45:25 -04:00
"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 OuterSubscriber_1 = require('../OuterSubscriber');
var subscribeToResult_1 = require('../util/subscribeToResult');
/**
* Returns an Observable that takes a source of observables and propagates the first observable exclusively
* until it completes before subscribing to the next.
* Items that come in before the first has exhausted will be dropped.
* Similar to `concatAll`, but will not hold on to items that come in before the first is exhausted.
* @returns {Observable} an Observable which contains all of the items of the first Observable and following Observables in the source.
*/
function exhaust() {
return this.lift(new SwitchFirstOperator());
}
exports.exhaust = exhaust;
var SwitchFirstOperator = (function () {
function SwitchFirstOperator() {
}
SwitchFirstOperator.prototype.call = function (subscriber) {
return new SwitchFirstSubscriber(subscriber);
};
return SwitchFirstOperator;
}());
var SwitchFirstSubscriber = (function (_super) {
__extends(SwitchFirstSubscriber, _super);
function SwitchFirstSubscriber(destination) {
_super.call(this, destination);
this.hasCompleted = false;
this.hasSubscription = false;
}
SwitchFirstSubscriber.prototype._next = function (value) {
if (!this.hasSubscription) {
this.hasSubscription = true;
this.add(subscribeToResult_1.subscribeToResult(this, value));
}
};
SwitchFirstSubscriber.prototype._complete = function () {
this.hasCompleted = true;
if (!this.hasSubscription) {
this.destination.complete();
}
};
SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
this.remove(innerSub);
this.hasSubscription = false;
if (this.hasCompleted) {
this.destination.complete();
}
};
return SwitchFirstSubscriber;
}(OuterSubscriber_1.OuterSubscriber));
//# sourceMappingURL=exhaust.js.map