UNPKG

1.65 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 return function (d, b) {
7 extendStatics(d, b);
8 function __() { this.constructor = d; }
9 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10 };
11})();
12Object.defineProperty(exports, "__esModule", { value: true });
13var Subscription_1 = require("./Subscription");
14var SubjectSubscription = (function (_super) {
15 __extends(SubjectSubscription, _super);
16 function SubjectSubscription(subject, subscriber) {
17 var _this = _super.call(this) || this;
18 _this.subject = subject;
19 _this.subscriber = subscriber;
20 _this.closed = false;
21 return _this;
22 }
23 SubjectSubscription.prototype.unsubscribe = function () {
24 if (this.closed) {
25 return;
26 }
27 this.closed = true;
28 var subject = this.subject;
29 var observers = subject.observers;
30 this.subject = null;
31 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
32 return;
33 }
34 var subscriberIndex = observers.indexOf(this.subscriber);
35 if (subscriberIndex !== -1) {
36 observers.splice(subscriberIndex, 1);
37 }
38 };
39 return SubjectSubscription;
40}(Subscription_1.Subscription));
41exports.SubjectSubscription = SubjectSubscription;
42//# sourceMappingURL=SubjectSubscription.js.map
\No newline at end of file