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

observeOn.js 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 Subscriber_1 = require("../Subscriber");
  17. var Notification_1 = require("../Notification");
  18. function observeOn(scheduler, delay) {
  19. if (delay === void 0) { delay = 0; }
  20. return function observeOnOperatorFunction(source) {
  21. return source.lift(new ObserveOnOperator(scheduler, delay));
  22. };
  23. }
  24. exports.observeOn = observeOn;
  25. var ObserveOnOperator = (function () {
  26. function ObserveOnOperator(scheduler, delay) {
  27. if (delay === void 0) { delay = 0; }
  28. this.scheduler = scheduler;
  29. this.delay = delay;
  30. }
  31. ObserveOnOperator.prototype.call = function (subscriber, source) {
  32. return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
  33. };
  34. return ObserveOnOperator;
  35. }());
  36. exports.ObserveOnOperator = ObserveOnOperator;
  37. var ObserveOnSubscriber = (function (_super) {
  38. __extends(ObserveOnSubscriber, _super);
  39. function ObserveOnSubscriber(destination, scheduler, delay) {
  40. if (delay === void 0) { delay = 0; }
  41. var _this = _super.call(this, destination) || this;
  42. _this.scheduler = scheduler;
  43. _this.delay = delay;
  44. return _this;
  45. }
  46. ObserveOnSubscriber.dispatch = function (arg) {
  47. var notification = arg.notification, destination = arg.destination;
  48. notification.observe(destination);
  49. this.unsubscribe();
  50. };
  51. ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
  52. var destination = this.destination;
  53. destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
  54. };
  55. ObserveOnSubscriber.prototype._next = function (value) {
  56. this.scheduleMessage(Notification_1.Notification.createNext(value));
  57. };
  58. ObserveOnSubscriber.prototype._error = function (err) {
  59. this.scheduleMessage(Notification_1.Notification.createError(err));
  60. this.unsubscribe();
  61. };
  62. ObserveOnSubscriber.prototype._complete = function () {
  63. this.scheduleMessage(Notification_1.Notification.createComplete());
  64. this.unsubscribe();
  65. };
  66. return ObserveOnSubscriber;
  67. }(Subscriber_1.Subscriber));
  68. exports.ObserveOnSubscriber = ObserveOnSubscriber;
  69. var ObserveOnMessage = (function () {
  70. function ObserveOnMessage(notification, destination) {
  71. this.notification = notification;
  72. this.destination = destination;
  73. }
  74. return ObserveOnMessage;
  75. }());
  76. exports.ObserveOnMessage = ObserveOnMessage;
  77. //# sourceMappingURL=observeOn.js.map