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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var empty_1 = require("./observable/empty");
  4. var of_1 = require("./observable/of");
  5. var throwError_1 = require("./observable/throwError");
  6. var NotificationKind;
  7. (function (NotificationKind) {
  8. NotificationKind["NEXT"] = "N";
  9. NotificationKind["ERROR"] = "E";
  10. NotificationKind["COMPLETE"] = "C";
  11. })(NotificationKind = exports.NotificationKind || (exports.NotificationKind = {}));
  12. var Notification = (function () {
  13. function Notification(kind, value, error) {
  14. this.kind = kind;
  15. this.value = value;
  16. this.error = error;
  17. this.hasValue = kind === 'N';
  18. }
  19. Notification.prototype.observe = function (observer) {
  20. switch (this.kind) {
  21. case 'N':
  22. return observer.next && observer.next(this.value);
  23. case 'E':
  24. return observer.error && observer.error(this.error);
  25. case 'C':
  26. return observer.complete && observer.complete();
  27. }
  28. };
  29. Notification.prototype.do = function (next, error, complete) {
  30. var kind = this.kind;
  31. switch (kind) {
  32. case 'N':
  33. return next && next(this.value);
  34. case 'E':
  35. return error && error(this.error);
  36. case 'C':
  37. return complete && complete();
  38. }
  39. };
  40. Notification.prototype.accept = function (nextOrObserver, error, complete) {
  41. if (nextOrObserver && typeof nextOrObserver.next === 'function') {
  42. return this.observe(nextOrObserver);
  43. }
  44. else {
  45. return this.do(nextOrObserver, error, complete);
  46. }
  47. };
  48. Notification.prototype.toObservable = function () {
  49. var kind = this.kind;
  50. switch (kind) {
  51. case 'N':
  52. return of_1.of(this.value);
  53. case 'E':
  54. return throwError_1.throwError(this.error);
  55. case 'C':
  56. return empty_1.empty();
  57. }
  58. throw new Error('unexpected notification kind value');
  59. };
  60. Notification.createNext = function (value) {
  61. if (typeof value !== 'undefined') {
  62. return new Notification('N', value);
  63. }
  64. return Notification.undefinedValueNotification;
  65. };
  66. Notification.createError = function (err) {
  67. return new Notification('E', undefined, err);
  68. };
  69. Notification.createComplete = function () {
  70. return Notification.completeNotification;
  71. };
  72. Notification.completeNotification = new Notification('C');
  73. Notification.undefinedValueNotification = new Notification('N', undefined);
  74. return Notification;
  75. }());
  76. exports.Notification = Notification;
  77. //# sourceMappingURL=Notification.js.map