source: trip-planner-front/node_modules/rxjs/_esm2015/internal/operators/window.js

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

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import { Subject } from '../Subject';
2import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
3export function window(windowBoundaries) {
4 return function windowOperatorFunction(source) {
5 return source.lift(new WindowOperator(windowBoundaries));
6 };
7}
8class WindowOperator {
9 constructor(windowBoundaries) {
10 this.windowBoundaries = windowBoundaries;
11 }
12 call(subscriber, source) {
13 const windowSubscriber = new WindowSubscriber(subscriber);
14 const sourceSubscription = source.subscribe(windowSubscriber);
15 if (!sourceSubscription.closed) {
16 windowSubscriber.add(innerSubscribe(this.windowBoundaries, new SimpleInnerSubscriber(windowSubscriber)));
17 }
18 return sourceSubscription;
19 }
20}
21class WindowSubscriber extends SimpleOuterSubscriber {
22 constructor(destination) {
23 super(destination);
24 this.window = new Subject();
25 destination.next(this.window);
26 }
27 notifyNext() {
28 this.openWindow();
29 }
30 notifyError(error) {
31 this._error(error);
32 }
33 notifyComplete() {
34 this._complete();
35 }
36 _next(value) {
37 this.window.next(value);
38 }
39 _error(err) {
40 this.window.error(err);
41 this.destination.error(err);
42 }
43 _complete() {
44 this.window.complete();
45 this.destination.complete();
46 }
47 _unsubscribe() {
48 this.window = null;
49 }
50 openWindow() {
51 const prevWindow = this.window;
52 if (prevWindow) {
53 prevWindow.complete();
54 }
55 const destination = this.destination;
56 const newWindow = this.window = new Subject();
57 destination.next(newWindow);
58 }
59}
60//# sourceMappingURL=window.js.map
Note: See TracBrowser for help on using the repository browser.