Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm2015 / internal / operators / windowWhen.js
1 import { Subject } from '../Subject';
2 import { OuterSubscriber } from '../OuterSubscriber';
3 import { subscribeToResult } from '../util/subscribeToResult';
4 export function windowWhen(closingSelector) {
5     return function windowWhenOperatorFunction(source) {
6         return source.lift(new WindowOperator(closingSelector));
7     };
8 }
9 class WindowOperator {
10     constructor(closingSelector) {
11         this.closingSelector = closingSelector;
12     }
13     call(subscriber, source) {
14         return source.subscribe(new WindowSubscriber(subscriber, this.closingSelector));
15     }
16 }
17 class WindowSubscriber extends OuterSubscriber {
18     constructor(destination, closingSelector) {
19         super(destination);
20         this.destination = destination;
21         this.closingSelector = closingSelector;
22         this.openWindow();
23     }
24     notifyNext(_outerValue, _innerValue, _outerIndex, _innerIndex, innerSub) {
25         this.openWindow(innerSub);
26     }
27     notifyError(error) {
28         this._error(error);
29     }
30     notifyComplete(innerSub) {
31         this.openWindow(innerSub);
32     }
33     _next(value) {
34         this.window.next(value);
35     }
36     _error(err) {
37         this.window.error(err);
38         this.destination.error(err);
39         this.unsubscribeClosingNotification();
40     }
41     _complete() {
42         this.window.complete();
43         this.destination.complete();
44         this.unsubscribeClosingNotification();
45     }
46     unsubscribeClosingNotification() {
47         if (this.closingNotification) {
48             this.closingNotification.unsubscribe();
49         }
50     }
51     openWindow(innerSub = null) {
52         if (innerSub) {
53             this.remove(innerSub);
54             innerSub.unsubscribe();
55         }
56         const prevWindow = this.window;
57         if (prevWindow) {
58             prevWindow.complete();
59         }
60         const window = this.window = new Subject();
61         this.destination.next(window);
62         let closingNotifier;
63         try {
64             const { closingSelector } = this;
65             closingNotifier = closingSelector();
66         }
67         catch (e) {
68             this.destination.error(e);
69             this.window.error(e);
70             return;
71         }
72         this.add(this.closingNotification = subscribeToResult(this, closingNotifier));
73     }
74 }
75 //# sourceMappingURL=windowWhen.js.map