rxjs
Version:
Reactive Extensions for modern JavaScript
27 lines • 1.18 kB
JavaScript
import { Subject } from '../Subject';
import { operate } from '../util/lift';
import { OperatorSubscriber } from './OperatorSubscriber';
import { noop } from '../util/noop';
export function window(windowBoundaries) {
return operate((source, subscriber) => {
let windowSubject = new Subject();
subscriber.next(windowSubject.asObservable());
const errorHandler = (err) => {
windowSubject.error(err);
subscriber.error(err);
};
source.subscribe(new OperatorSubscriber(subscriber, (value) => windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.next(value), () => {
windowSubject.complete();
subscriber.complete();
}, errorHandler));
windowBoundaries.subscribe(new OperatorSubscriber(subscriber, () => {
windowSubject.complete();
subscriber.next((windowSubject = new Subject()));
}, noop, errorHandler));
return () => {
windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.unsubscribe();
windowSubject = null;
};
});
}
//# sourceMappingURL=window.js.map