Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /** PURE_IMPORTS_START tslib,_Subject,_Subscription PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { Subject } from './Subject';
  4. import { Subscription } from './Subscription';
  5. var AsyncSubject = /*@__PURE__*/ (function (_super) {
  6. tslib_1.__extends(AsyncSubject, _super);
  7. function AsyncSubject() {
  8. var _this = _super !== null && _super.apply(this, arguments) || this;
  9. _this.value = null;
  10. _this.hasNext = false;
  11. _this.hasCompleted = false;
  12. return _this;
  13. }
  14. AsyncSubject.prototype._subscribe = function (subscriber) {
  15. if (this.hasError) {
  16. subscriber.error(this.thrownError);
  17. return Subscription.EMPTY;
  18. }
  19. else if (this.hasCompleted && this.hasNext) {
  20. subscriber.next(this.value);
  21. subscriber.complete();
  22. return Subscription.EMPTY;
  23. }
  24. return _super.prototype._subscribe.call(this, subscriber);
  25. };
  26. AsyncSubject.prototype.next = function (value) {
  27. if (!this.hasCompleted) {
  28. this.value = value;
  29. this.hasNext = true;
  30. }
  31. };
  32. AsyncSubject.prototype.error = function (error) {
  33. if (!this.hasCompleted) {
  34. _super.prototype.error.call(this, error);
  35. }
  36. };
  37. AsyncSubject.prototype.complete = function () {
  38. this.hasCompleted = true;
  39. if (this.hasNext) {
  40. _super.prototype.next.call(this, this.value);
  41. }
  42. _super.prototype.complete.call(this);
  43. };
  44. return AsyncSubject;
  45. }(Subject));
  46. export { AsyncSubject };
  47. //# sourceMappingURL=AsyncSubject.js.map