AsyncSubject.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { __extends } from "tslib";
  2. import { Subject } from './Subject';
  3. var AsyncSubject = (function (_super) {
  4. __extends(AsyncSubject, _super);
  5. function AsyncSubject() {
  6. var _this = _super !== null && _super.apply(this, arguments) || this;
  7. _this._value = null;
  8. _this._hasValue = false;
  9. _this._isComplete = false;
  10. return _this;
  11. }
  12. AsyncSubject.prototype._checkFinalizedStatuses = function (subscriber) {
  13. var _a = this, hasError = _a.hasError, _hasValue = _a._hasValue, _value = _a._value, thrownError = _a.thrownError, isStopped = _a.isStopped, _isComplete = _a._isComplete;
  14. if (hasError) {
  15. subscriber.error(thrownError);
  16. }
  17. else if (isStopped || _isComplete) {
  18. _hasValue && subscriber.next(_value);
  19. subscriber.complete();
  20. }
  21. };
  22. AsyncSubject.prototype.next = function (value) {
  23. if (!this.isStopped) {
  24. this._value = value;
  25. this._hasValue = true;
  26. }
  27. };
  28. AsyncSubject.prototype.complete = function () {
  29. var _a = this, _hasValue = _a._hasValue, _value = _a._value, _isComplete = _a._isComplete;
  30. if (!_isComplete) {
  31. this._isComplete = true;
  32. _hasValue && _super.prototype.next.call(this, _value);
  33. _super.prototype.complete.call(this);
  34. }
  35. };
  36. return AsyncSubject;
  37. }(Subject));
  38. export { AsyncSubject };
  39. //# sourceMappingURL=AsyncSubject.js.map