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