1 | "use strict";
|
---|
2 | var __extends = (this && this.__extends) || (function () {
|
---|
3 | var extendStatics = function (d, b) {
|
---|
4 | extendStatics = Object.setPrototypeOf ||
|
---|
5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
---|
6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
---|
7 | return extendStatics(d, b);
|
---|
8 | }
|
---|
9 | return function (d, b) {
|
---|
10 | extendStatics(d, b);
|
---|
11 | function __() { this.constructor = d; }
|
---|
12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
---|
13 | };
|
---|
14 | })();
|
---|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
16 | var innerSubscribe_1 = require("../innerSubscribe");
|
---|
17 | function exhaust() {
|
---|
18 | return function (source) { return source.lift(new SwitchFirstOperator()); };
|
---|
19 | }
|
---|
20 | exports.exhaust = exhaust;
|
---|
21 | var SwitchFirstOperator = (function () {
|
---|
22 | function SwitchFirstOperator() {
|
---|
23 | }
|
---|
24 | SwitchFirstOperator.prototype.call = function (subscriber, source) {
|
---|
25 | return source.subscribe(new SwitchFirstSubscriber(subscriber));
|
---|
26 | };
|
---|
27 | return SwitchFirstOperator;
|
---|
28 | }());
|
---|
29 | var SwitchFirstSubscriber = (function (_super) {
|
---|
30 | __extends(SwitchFirstSubscriber, _super);
|
---|
31 | function SwitchFirstSubscriber(destination) {
|
---|
32 | var _this = _super.call(this, destination) || this;
|
---|
33 | _this.hasCompleted = false;
|
---|
34 | _this.hasSubscription = false;
|
---|
35 | return _this;
|
---|
36 | }
|
---|
37 | SwitchFirstSubscriber.prototype._next = function (value) {
|
---|
38 | if (!this.hasSubscription) {
|
---|
39 | this.hasSubscription = true;
|
---|
40 | this.add(innerSubscribe_1.innerSubscribe(value, new innerSubscribe_1.SimpleInnerSubscriber(this)));
|
---|
41 | }
|
---|
42 | };
|
---|
43 | SwitchFirstSubscriber.prototype._complete = function () {
|
---|
44 | this.hasCompleted = true;
|
---|
45 | if (!this.hasSubscription) {
|
---|
46 | this.destination.complete();
|
---|
47 | }
|
---|
48 | };
|
---|
49 | SwitchFirstSubscriber.prototype.notifyComplete = function () {
|
---|
50 | this.hasSubscription = false;
|
---|
51 | if (this.hasCompleted) {
|
---|
52 | this.destination.complete();
|
---|
53 | }
|
---|
54 | };
|
---|
55 | return SwitchFirstSubscriber;
|
---|
56 | }(innerSubscribe_1.SimpleOuterSubscriber));
|
---|
57 | //# sourceMappingURL=exhaust.js.map |
---|