You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.7 KiB
50 lines
1.7 KiB
/** PURE_IMPORTS_START ._Subject,._util_ObjectUnsubscribedError PURE_IMPORTS_END */ |
|
var __extends = (this && this.__extends) || function (d, b) { |
|
for (var p in b) |
|
if (b.hasOwnProperty(p)) |
|
d[p] = b[p]; |
|
function __() { this.constructor = d; } |
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
}; |
|
import { Subject } from './Subject'; |
|
import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError'; |
|
/** |
|
* @class BehaviorSubject<T> |
|
*/ |
|
export var BehaviorSubject = /*@__PURE__*/ (/*@__PURE__*/ function (_super) { |
|
__extends(BehaviorSubject, _super); |
|
function BehaviorSubject(_value) { |
|
_super.call(this); |
|
this._value = _value; |
|
} |
|
Object.defineProperty(BehaviorSubject.prototype, "value", { |
|
get: function () { |
|
return this.getValue(); |
|
}, |
|
enumerable: true, |
|
configurable: true |
|
}); |
|
/** @deprecated internal use only */ 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)); |
|
//# sourceMappingURL=BehaviorSubject.js.map
|
|
|