window.js 1.3 KB

12345678910111213141516171819202122232425262728
  1. import { Subject } from '../Subject';
  2. import { operate } from '../util/lift';
  3. import { createOperatorSubscriber } from './OperatorSubscriber';
  4. import { noop } from '../util/noop';
  5. import { innerFrom } from '../observable/innerFrom';
  6. export function window(windowBoundaries) {
  7. return operate(function (source, subscriber) {
  8. var windowSubject = new Subject();
  9. subscriber.next(windowSubject.asObservable());
  10. var errorHandler = function (err) {
  11. windowSubject.error(err);
  12. subscriber.error(err);
  13. };
  14. source.subscribe(createOperatorSubscriber(subscriber, function (value) { return windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.next(value); }, function () {
  15. windowSubject.complete();
  16. subscriber.complete();
  17. }, errorHandler));
  18. innerFrom(windowBoundaries).subscribe(createOperatorSubscriber(subscriber, function () {
  19. windowSubject.complete();
  20. subscriber.next((windowSubject = new Subject()));
  21. }, noop, errorHandler));
  22. return function () {
  23. windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.unsubscribe();
  24. windowSubject = null;
  25. };
  26. });
  27. }
  28. //# sourceMappingURL=window.js.map