UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

49 lines 1.96 kB
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 __()); }; define(["require", "exports", './Subject', './util/throwError', './util/ObjectUnsubscribedError'], function (require, exports, Subject_1, throwError_1, ObjectUnsubscribedError_1) { "use strict"; /** * @class BehaviorSubject<T> */ var BehaviorSubject = (function (_super) { __extends(BehaviorSubject, _super); function BehaviorSubject(_value) { _super.call(this); this._value = _value; } BehaviorSubject.prototype.getValue = function () { if (this.hasError) { throwError_1.throwError(this.thrownError); } else if (this.isUnsubscribed) { throwError_1.throwError(new ObjectUnsubscribedError_1.ObjectUnsubscribedError()); } else { return this._value; } }; 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.isUnsubscribed) { subscriber.next(this._value); } return subscription; }; BehaviorSubject.prototype.next = function (value) { _super.prototype.next.call(this, this._value = value); }; return BehaviorSubject; }(Subject_1.Subject)); exports.BehaviorSubject = BehaviorSubject; }); //# sourceMappingURL=BehaviorSubject.js.map