This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/rxjs/_esm2015/internal/operators/window.js

61 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
import { Subject } from '../Subject';
import { OuterSubscriber } from '../OuterSubscriber';
import { subscribeToResult } from '../util/subscribeToResult';
export function window(windowBoundaries) {
return function windowOperatorFunction(source) {
return source.lift(new WindowOperator(windowBoundaries));
};
}
class WindowOperator {
constructor(windowBoundaries) {
this.windowBoundaries = windowBoundaries;
}
call(subscriber, source) {
const windowSubscriber = new WindowSubscriber(subscriber);
const sourceSubscription = source.subscribe(windowSubscriber);
if (!sourceSubscription.closed) {
windowSubscriber.add(subscribeToResult(windowSubscriber, this.windowBoundaries));
}
return sourceSubscription;
}
}
class WindowSubscriber extends OuterSubscriber {
constructor(destination) {
super(destination);
this.window = new Subject();
destination.next(this.window);
}
notifyNext(outerValue, innerValue, outerIndex, innerIndex, innerSub) {
this.openWindow();
}
notifyError(error, innerSub) {
this._error(error);
}
notifyComplete(innerSub) {
this._complete();
}
_next(value) {
this.window.next(value);
}
_error(err) {
this.window.error(err);
this.destination.error(err);
}
_complete() {
this.window.complete();
this.destination.complete();
}
_unsubscribe() {
this.window = null;
}
openWindow() {
const prevWindow = this.window;
if (prevWindow) {
prevWindow.complete();
}
const destination = this.destination;
const newWindow = this.window = new Subject();
destination.next(newWindow);
}
}
//# sourceMappingURL=window.js.map