source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/windowWhen.js@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subject,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subject } from '../Subject';
4import { OuterSubscriber } from '../OuterSubscriber';
5import { subscribeToResult } from '../util/subscribeToResult';
6export function windowWhen(closingSelector) {
7 return function windowWhenOperatorFunction(source) {
8 return source.lift(new WindowOperator(closingSelector));
9 };
10}
11var WindowOperator = /*@__PURE__*/ (function () {
12 function WindowOperator(closingSelector) {
13 this.closingSelector = closingSelector;
14 }
15 WindowOperator.prototype.call = function (subscriber, source) {
16 return source.subscribe(new WindowSubscriber(subscriber, this.closingSelector));
17 };
18 return WindowOperator;
19}());
20var WindowSubscriber = /*@__PURE__*/ (function (_super) {
21 tslib_1.__extends(WindowSubscriber, _super);
22 function WindowSubscriber(destination, closingSelector) {
23 var _this = _super.call(this, destination) || this;
24 _this.destination = destination;
25 _this.closingSelector = closingSelector;
26 _this.openWindow();
27 return _this;
28 }
29 WindowSubscriber.prototype.notifyNext = function (_outerValue, _innerValue, _outerIndex, _innerIndex, innerSub) {
30 this.openWindow(innerSub);
31 };
32 WindowSubscriber.prototype.notifyError = function (error) {
33 this._error(error);
34 };
35 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
36 this.openWindow(innerSub);
37 };
38 WindowSubscriber.prototype._next = function (value) {
39 this.window.next(value);
40 };
41 WindowSubscriber.prototype._error = function (err) {
42 this.window.error(err);
43 this.destination.error(err);
44 this.unsubscribeClosingNotification();
45 };
46 WindowSubscriber.prototype._complete = function () {
47 this.window.complete();
48 this.destination.complete();
49 this.unsubscribeClosingNotification();
50 };
51 WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
52 if (this.closingNotification) {
53 this.closingNotification.unsubscribe();
54 }
55 };
56 WindowSubscriber.prototype.openWindow = function (innerSub) {
57 if (innerSub === void 0) {
58 innerSub = null;
59 }
60 if (innerSub) {
61 this.remove(innerSub);
62 innerSub.unsubscribe();
63 }
64 var prevWindow = this.window;
65 if (prevWindow) {
66 prevWindow.complete();
67 }
68 var window = this.window = new Subject();
69 this.destination.next(window);
70 var closingNotifier;
71 try {
72 var closingSelector = this.closingSelector;
73 closingNotifier = closingSelector();
74 }
75 catch (e) {
76 this.destination.error(e);
77 this.window.error(e);
78 return;
79 }
80 this.add(this.closingNotification = subscribeToResult(this, closingNotifier));
81 };
82 return WindowSubscriber;
83}(OuterSubscriber));
84//# sourceMappingURL=windowWhen.js.map
Note: See TracBrowser for help on using the repository browser.