| 1 |
import { Subject } from '../Subject'; |
| 2 |
import { operate } from '../util/lift'; |
| 3 |
import { createOperatorSubscriber } from './OperatorSubscriber'; |
| 4 |
import { innerFrom } from '../observable/innerFrom'; |
| 5 |
export function windowWhen(closingSelector) { |
| 6 |
return operate(function (source, subscriber) { |
| 7 |
var window; |
| 8 |
var closingSubscriber; |
| 9 |
var handleError = function (err) { |
| 10 |
window.error(err); |
| 11 |
subscriber.error(err); |
| 12 |
}; |
| 13 |
var openWindow = function () { |
| 14 |
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe(); |
| 15 |
window === null || window === void 0 ? void 0 : window.complete(); |
| 16 |
window = new Subject(); |
| 17 |
subscriber.next(window.asObservable()); |
| 18 |
var closingNotifier; |
| 19 |
try { |
| 20 |
closingNotifier = innerFrom(closingSelector()); |
| 21 |
} |
| 22 |
catch (err) { |
| 23 |
handleError(err); |
| 24 |
return; |
| 25 |
} |
| 26 |
closingNotifier.subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openWindow, openWindow, handleError))); |
| 27 |
}; |
| 28 |
openWindow(); |
| 29 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return window.next(value); }, function () { |
| 30 |
window.complete(); |
| 31 |
subscriber.complete(); |
| 32 |
}, handleError, function () { |
| 33 |
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe(); |
| 34 |
window = null; |
| 35 |
})); |
| 36 |
}); |
| 37 |
} |
| 38 |
//# sourceMappingURL=windowWhen.js.map |