a zip code crypto-currency system good for red ONLY

BehaviorSubject.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /** PURE_IMPORTS_START ._Subject,._util_ObjectUnsubscribedError PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { Subject } from './Subject';
  10. import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';
  11. /**
  12. * @class BehaviorSubject<T>
  13. */
  14. export var BehaviorSubject = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  15. __extends(BehaviorSubject, _super);
  16. function BehaviorSubject(_value) {
  17. _super.call(this);
  18. this._value = _value;
  19. }
  20. Object.defineProperty(BehaviorSubject.prototype, "value", {
  21. get: function () {
  22. return this.getValue();
  23. },
  24. enumerable: true,
  25. configurable: true
  26. });
  27. /** @deprecated internal use only */ BehaviorSubject.prototype._subscribe = function (subscriber) {
  28. var subscription = _super.prototype._subscribe.call(this, subscriber);
  29. if (subscription && !subscription.closed) {
  30. subscriber.next(this._value);
  31. }
  32. return subscription;
  33. };
  34. BehaviorSubject.prototype.getValue = function () {
  35. if (this.hasError) {
  36. throw this.thrownError;
  37. }
  38. else if (this.closed) {
  39. throw new ObjectUnsubscribedError();
  40. }
  41. else {
  42. return this._value;
  43. }
  44. };
  45. BehaviorSubject.prototype.next = function (value) {
  46. _super.prototype.next.call(this, this._value = value);
  47. };
  48. return BehaviorSubject;
  49. }(Subject));
  50. //# sourceMappingURL=BehaviorSubject.js.map