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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 Subscription_1 = require("./Subscription");
  18. var AsyncSubject = (function (_super) {
  19. __extends(AsyncSubject, _super);
  20. function AsyncSubject() {
  21. var _this = _super !== null && _super.apply(this, arguments) || this;
  22. _this.value = null;
  23. _this.hasNext = false;
  24. _this.hasCompleted = false;
  25. return _this;
  26. }
  27. AsyncSubject.prototype._subscribe = function (subscriber) {
  28. if (this.hasError) {
  29. subscriber.error(this.thrownError);
  30. return Subscription_1.Subscription.EMPTY;
  31. }
  32. else if (this.hasCompleted && this.hasNext) {
  33. subscriber.next(this.value);
  34. subscriber.complete();
  35. return Subscription_1.Subscription.EMPTY;
  36. }
  37. return _super.prototype._subscribe.call(this, subscriber);
  38. };
  39. AsyncSubject.prototype.next = function (value) {
  40. if (!this.hasCompleted) {
  41. this.value = value;
  42. this.hasNext = true;
  43. }
  44. };
  45. AsyncSubject.prototype.error = function (error) {
  46. if (!this.hasCompleted) {
  47. _super.prototype.error.call(this, error);
  48. }
  49. };
  50. AsyncSubject.prototype.complete = function () {
  51. this.hasCompleted = true;
  52. if (this.hasNext) {
  53. _super.prototype.next.call(this, this.value);
  54. }
  55. _super.prototype.complete.call(this);
  56. };
  57. return AsyncSubject;
  58. }(Subject_1.Subject));
  59. exports.AsyncSubject = AsyncSubject;
  60. //# sourceMappingURL=AsyncSubject.js.map