wishthis/node_modules/rxjs/dist/esm5/internal/operators/window.js

28 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-06-08 10:36:39 +00:00
import { Subject } from '../Subject';
import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { noop } from '../util/noop';
2023-02-08 12:35:10 +00:00
import { innerFrom } from '../observable/innerFrom';
2022-06-08 10:36:39 +00:00
export function window(windowBoundaries) {
return operate(function (source, subscriber) {
var windowSubject = new Subject();
subscriber.next(windowSubject.asObservable());
var errorHandler = function (err) {
windowSubject.error(err);
subscriber.error(err);
};
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.next(value); }, function () {
windowSubject.complete();
subscriber.complete();
}, errorHandler));
2023-02-08 12:35:10 +00:00
innerFrom(windowBoundaries).subscribe(createOperatorSubscriber(subscriber, function () {
2022-06-08 10:36:39 +00:00
windowSubject.complete();
subscriber.next((windowSubject = new Subject()));
}, noop, errorHandler));
return function () {
windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.unsubscribe();
windowSubject = null;
};
});
}
//# sourceMappingURL=window.js.map