2022-01-21 08:28:41 +00:00
|
|
|
"use strict";
|
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
|
|
var extendStatics = function (d, b) {
|
|
|
|
extendStatics = Object.setPrototypeOf ||
|
|
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
2022-05-29 09:24:36 +00:00
|
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
2022-01-21 08:28:41 +00:00
|
|
|
return extendStatics(d, b);
|
2022-05-29 09:24:36 +00:00
|
|
|
}
|
2022-01-21 08:28:41 +00:00
|
|
|
return function (d, b) {
|
|
|
|
extendStatics(d, b);
|
|
|
|
function __() { this.constructor = d; }
|
|
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var Subject_1 = require("./Subject");
|
2022-05-29 09:24:36 +00:00
|
|
|
var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
|
2022-01-21 08:28:41 +00:00
|
|
|
var BehaviorSubject = (function (_super) {
|
|
|
|
__extends(BehaviorSubject, _super);
|
|
|
|
function BehaviorSubject(_value) {
|
|
|
|
var _this = _super.call(this) || this;
|
|
|
|
_this._value = _value;
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
Object.defineProperty(BehaviorSubject.prototype, "value", {
|
|
|
|
get: function () {
|
|
|
|
return this.getValue();
|
|
|
|
},
|
2022-05-29 09:24:36 +00:00
|
|
|
enumerable: true,
|
2022-01-21 08:28:41 +00:00
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
BehaviorSubject.prototype._subscribe = function (subscriber) {
|
|
|
|
var subscription = _super.prototype._subscribe.call(this, subscriber);
|
2022-05-29 09:24:36 +00:00
|
|
|
if (subscription && !subscription.closed) {
|
|
|
|
subscriber.next(this._value);
|
|
|
|
}
|
2022-01-21 08:28:41 +00:00
|
|
|
return subscription;
|
|
|
|
};
|
|
|
|
BehaviorSubject.prototype.getValue = function () {
|
2022-05-29 09:24:36 +00:00
|
|
|
if (this.hasError) {
|
|
|
|
throw this.thrownError;
|
|
|
|
}
|
|
|
|
else if (this.closed) {
|
|
|
|
throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return this._value;
|
2022-01-21 08:28:41 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
BehaviorSubject.prototype.next = function (value) {
|
2022-05-29 09:24:36 +00:00
|
|
|
_super.prototype.next.call(this, this._value = value);
|
2022-01-21 08:28:41 +00:00
|
|
|
};
|
|
|
|
return BehaviorSubject;
|
|
|
|
}(Subject_1.Subject));
|
|
|
|
exports.BehaviorSubject = BehaviorSubject;
|
|
|
|
//# sourceMappingURL=BehaviorSubject.js.map
|