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

window.js 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 innerSubscribe_1 = require("../innerSubscribe");
  18. function window(windowBoundaries) {
  19. return function windowOperatorFunction(source) {
  20. return source.lift(new WindowOperator(windowBoundaries));
  21. };
  22. }
  23. exports.window = window;
  24. var WindowOperator = (function () {
  25. function WindowOperator(windowBoundaries) {
  26. this.windowBoundaries = windowBoundaries;
  27. }
  28. WindowOperator.prototype.call = function (subscriber, source) {
  29. var windowSubscriber = new WindowSubscriber(subscriber);
  30. var sourceSubscription = source.subscribe(windowSubscriber);
  31. if (!sourceSubscription.closed) {
  32. windowSubscriber.add(innerSubscribe_1.innerSubscribe(this.windowBoundaries, new innerSubscribe_1.SimpleInnerSubscriber(windowSubscriber)));
  33. }
  34. return sourceSubscription;
  35. };
  36. return WindowOperator;
  37. }());
  38. var WindowSubscriber = (function (_super) {
  39. __extends(WindowSubscriber, _super);
  40. function WindowSubscriber(destination) {
  41. var _this = _super.call(this, destination) || this;
  42. _this.window = new Subject_1.Subject();
  43. destination.next(_this.window);
  44. return _this;
  45. }
  46. WindowSubscriber.prototype.notifyNext = function () {
  47. this.openWindow();
  48. };
  49. WindowSubscriber.prototype.notifyError = function (error) {
  50. this._error(error);
  51. };
  52. WindowSubscriber.prototype.notifyComplete = function () {
  53. this._complete();
  54. };
  55. WindowSubscriber.prototype._next = function (value) {
  56. this.window.next(value);
  57. };
  58. WindowSubscriber.prototype._error = function (err) {
  59. this.window.error(err);
  60. this.destination.error(err);
  61. };
  62. WindowSubscriber.prototype._complete = function () {
  63. this.window.complete();
  64. this.destination.complete();
  65. };
  66. WindowSubscriber.prototype._unsubscribe = function () {
  67. this.window = null;
  68. };
  69. WindowSubscriber.prototype.openWindow = function () {
  70. var prevWindow = this.window;
  71. if (prevWindow) {
  72. prevWindow.complete();
  73. }
  74. var destination = this.destination;
  75. var newWindow = this.window = new Subject_1.Subject();
  76. destination.next(newWindow);
  77. };
  78. return WindowSubscriber;
  79. }(innerSubscribe_1.SimpleOuterSubscriber));
  80. //# sourceMappingURL=window.js.map