source: trip-planner-front/node_modules/rxjs/internal/Subject.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.9 KB
Line 
1"use strict";
2var __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})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var Observable_1 = require("./Observable");
17var Subscriber_1 = require("./Subscriber");
18var Subscription_1 = require("./Subscription");
19var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
20var SubjectSubscription_1 = require("./SubjectSubscription");
21var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
22var SubjectSubscriber = (function (_super) {
23 __extends(SubjectSubscriber, _super);
24 function SubjectSubscriber(destination) {
25 var _this = _super.call(this, destination) || this;
26 _this.destination = destination;
27 return _this;
28 }
29 return SubjectSubscriber;
30}(Subscriber_1.Subscriber));
31exports.SubjectSubscriber = SubjectSubscriber;
32var Subject = (function (_super) {
33 __extends(Subject, _super);
34 function Subject() {
35 var _this = _super.call(this) || this;
36 _this.observers = [];
37 _this.closed = false;
38 _this.isStopped = false;
39 _this.hasError = false;
40 _this.thrownError = null;
41 return _this;
42 }
43 Subject.prototype[rxSubscriber_1.rxSubscriber] = function () {
44 return new SubjectSubscriber(this);
45 };
46 Subject.prototype.lift = function (operator) {
47 var subject = new AnonymousSubject(this, this);
48 subject.operator = operator;
49 return subject;
50 };
51 Subject.prototype.next = function (value) {
52 if (this.closed) {
53 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
54 }
55 if (!this.isStopped) {
56 var observers = this.observers;
57 var len = observers.length;
58 var copy = observers.slice();
59 for (var i = 0; i < len; i++) {
60 copy[i].next(value);
61 }
62 }
63 };
64 Subject.prototype.error = function (err) {
65 if (this.closed) {
66 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
67 }
68 this.hasError = true;
69 this.thrownError = err;
70 this.isStopped = true;
71 var observers = this.observers;
72 var len = observers.length;
73 var copy = observers.slice();
74 for (var i = 0; i < len; i++) {
75 copy[i].error(err);
76 }
77 this.observers.length = 0;
78 };
79 Subject.prototype.complete = function () {
80 if (this.closed) {
81 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
82 }
83 this.isStopped = true;
84 var observers = this.observers;
85 var len = observers.length;
86 var copy = observers.slice();
87 for (var i = 0; i < len; i++) {
88 copy[i].complete();
89 }
90 this.observers.length = 0;
91 };
92 Subject.prototype.unsubscribe = function () {
93 this.isStopped = true;
94 this.closed = true;
95 this.observers = null;
96 };
97 Subject.prototype._trySubscribe = function (subscriber) {
98 if (this.closed) {
99 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
100 }
101 else {
102 return _super.prototype._trySubscribe.call(this, subscriber);
103 }
104 };
105 Subject.prototype._subscribe = function (subscriber) {
106 if (this.closed) {
107 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
108 }
109 else if (this.hasError) {
110 subscriber.error(this.thrownError);
111 return Subscription_1.Subscription.EMPTY;
112 }
113 else if (this.isStopped) {
114 subscriber.complete();
115 return Subscription_1.Subscription.EMPTY;
116 }
117 else {
118 this.observers.push(subscriber);
119 return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
120 }
121 };
122 Subject.prototype.asObservable = function () {
123 var observable = new Observable_1.Observable();
124 observable.source = this;
125 return observable;
126 };
127 Subject.create = function (destination, source) {
128 return new AnonymousSubject(destination, source);
129 };
130 return Subject;
131}(Observable_1.Observable));
132exports.Subject = Subject;
133var AnonymousSubject = (function (_super) {
134 __extends(AnonymousSubject, _super);
135 function AnonymousSubject(destination, source) {
136 var _this = _super.call(this) || this;
137 _this.destination = destination;
138 _this.source = source;
139 return _this;
140 }
141 AnonymousSubject.prototype.next = function (value) {
142 var destination = this.destination;
143 if (destination && destination.next) {
144 destination.next(value);
145 }
146 };
147 AnonymousSubject.prototype.error = function (err) {
148 var destination = this.destination;
149 if (destination && destination.error) {
150 this.destination.error(err);
151 }
152 };
153 AnonymousSubject.prototype.complete = function () {
154 var destination = this.destination;
155 if (destination && destination.complete) {
156 this.destination.complete();
157 }
158 };
159 AnonymousSubject.prototype._subscribe = function (subscriber) {
160 var source = this.source;
161 if (source) {
162 return this.source.subscribe(subscriber);
163 }
164 else {
165 return Subscription_1.Subscription.EMPTY;
166 }
167 };
168 return AnonymousSubject;
169}(Subject));
170exports.AnonymousSubject = AnonymousSubject;
171//# sourceMappingURL=Subject.js.map
Note: See TracBrowser for help on using the repository browser.