rxjs
Version:
Reactive Extensions for modern JavaScript
27 lines • 968 B
JavaScript
import { innerFrom } from '../observable/innerFrom';
import { OperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../util/lift';
export function catchError(selector) {
return operate(function (source, subscriber) {
var innerSub = null;
var syncUnsub = false;
var handledResult;
innerSub = source.subscribe(new OperatorSubscriber(subscriber, undefined, undefined, function (err) {
handledResult = innerFrom(selector(err, catchError(selector)(source)));
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
handledResult.subscribe(subscriber);
}
else {
syncUnsub = true;
}
}));
if (syncUnsub) {
innerSub.unsubscribe();
innerSub = null;
handledResult.subscribe(subscriber);
}
});
}
//# sourceMappingURL=catchError.js.map