UNPKG

1.97 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 Subject_1 = require("./Subject");
14var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
15var BehaviorSubject = (function (_super) {
16 __extends(BehaviorSubject, _super);
17 function BehaviorSubject(_value) {
18 var _this = _super.call(this) || this;
19 _this._value = _value;
20 return _this;
21 }
22 Object.defineProperty(BehaviorSubject.prototype, "value", {
23 get: function () {
24 return this.getValue();
25 },
26 enumerable: true,
27 configurable: true
28 });
29 BehaviorSubject.prototype._subscribe = function (subscriber) {
30 var subscription = _super.prototype._subscribe.call(this, subscriber);
31 if (subscription && !subscription.closed) {
32 subscriber.next(this._value);
33 }
34 return subscription;
35 };
36 BehaviorSubject.prototype.getValue = function () {
37 if (this.hasError) {
38 throw this.thrownError;
39 }
40 else if (this.closed) {
41 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
42 }
43 else {
44 return this._value;
45 }
46 };
47 BehaviorSubject.prototype.next = function (value) {
48 _super.prototype.next.call(this, this._value = value);
49 };
50 return BehaviorSubject;
51}(Subject_1.Subject));
52exports.BehaviorSubject = BehaviorSubject;
53//# sourceMappingURL=BehaviorSubject.js.map
\No newline at end of file