|
12345678910111213141516171819202122232425262728293031323334353637383940414243 |
-
- import * as tslib_1 from "tslib";
- import { Subject } from './Subject';
- import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';
- var BehaviorSubject = (function (_super) {
- tslib_1.__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();
- },
- enumerable: true,
- configurable: true
- });
- BehaviorSubject.prototype._subscribe = function (subscriber) {
- var subscription = _super.prototype._subscribe.call(this, subscriber);
- if (subscription && !subscription.closed) {
- subscriber.next(this._value);
- }
- return subscription;
- };
- BehaviorSubject.prototype.getValue = function () {
- if (this.hasError) {
- throw this.thrownError;
- }
- else if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- else {
- return this._value;
- }
- };
- BehaviorSubject.prototype.next = function (value) {
- _super.prototype.next.call(this, this._value = value);
- };
- return BehaviorSubject;
- }(Subject));
- export { BehaviorSubject };
-
|