source: trip-planner-front/node_modules/rxjs/internal/operators/windowWhen.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.6 KB
Line 
1"use strict";
2var __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})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var Subject_1 = require("../Subject");
17var OuterSubscriber_1 = require("../OuterSubscriber");
18var subscribeToResult_1 = require("../util/subscribeToResult");
19function windowWhen(closingSelector) {
20 return function windowWhenOperatorFunction(source) {
21 return source.lift(new WindowOperator(closingSelector));
22 };
23}
24exports.windowWhen = windowWhen;
25var WindowOperator = (function () {
26 function WindowOperator(closingSelector) {
27 this.closingSelector = closingSelector;
28 }
29 WindowOperator.prototype.call = function (subscriber, source) {
30 return source.subscribe(new WindowSubscriber(subscriber, this.closingSelector));
31 };
32 return WindowOperator;
33}());
34var WindowSubscriber = (function (_super) {
35 __extends(WindowSubscriber, _super);
36 function WindowSubscriber(destination, closingSelector) {
37 var _this = _super.call(this, destination) || this;
38 _this.destination = destination;
39 _this.closingSelector = closingSelector;
40 _this.openWindow();
41 return _this;
42 }
43 WindowSubscriber.prototype.notifyNext = function (_outerValue, _innerValue, _outerIndex, _innerIndex, innerSub) {
44 this.openWindow(innerSub);
45 };
46 WindowSubscriber.prototype.notifyError = function (error) {
47 this._error(error);
48 };
49 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
50 this.openWindow(innerSub);
51 };
52 WindowSubscriber.prototype._next = function (value) {
53 this.window.next(value);
54 };
55 WindowSubscriber.prototype._error = function (err) {
56 this.window.error(err);
57 this.destination.error(err);
58 this.unsubscribeClosingNotification();
59 };
60 WindowSubscriber.prototype._complete = function () {
61 this.window.complete();
62 this.destination.complete();
63 this.unsubscribeClosingNotification();
64 };
65 WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
66 if (this.closingNotification) {
67 this.closingNotification.unsubscribe();
68 }
69 };
70 WindowSubscriber.prototype.openWindow = function (innerSub) {
71 if (innerSub === void 0) { innerSub = null; }
72 if (innerSub) {
73 this.remove(innerSub);
74 innerSub.unsubscribe();
75 }
76 var prevWindow = this.window;
77 if (prevWindow) {
78 prevWindow.complete();
79 }
80 var window = this.window = new Subject_1.Subject();
81 this.destination.next(window);
82 var closingNotifier;
83 try {
84 var closingSelector = this.closingSelector;
85 closingNotifier = closingSelector();
86 }
87 catch (e) {
88 this.destination.error(e);
89 this.window.error(e);
90 return;
91 }
92 this.add(this.closingNotification = subscribeToResult_1.subscribeToResult(this, closingNotifier));
93 };
94 return WindowSubscriber;
95}(OuterSubscriber_1.OuterSubscriber));
96//# sourceMappingURL=windowWhen.js.map
Note: See TracBrowser for help on using the repository browser.