catchError.js 976 B

123456789101112131415161718192021222324252627
  1. import { innerFrom } from '../observable/innerFrom';
  2. import { createOperatorSubscriber } from './OperatorSubscriber';
  3. import { operate } from '../util/lift';
  4. export function catchError(selector) {
  5. return operate(function (source, subscriber) {
  6. var innerSub = null;
  7. var syncUnsub = false;
  8. var handledResult;
  9. innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
  10. handledResult = innerFrom(selector(err, catchError(selector)(source)));
  11. if (innerSub) {
  12. innerSub.unsubscribe();
  13. innerSub = null;
  14. handledResult.subscribe(subscriber);
  15. }
  16. else {
  17. syncUnsub = true;
  18. }
  19. }));
  20. if (syncUnsub) {
  21. innerSub.unsubscribe();
  22. innerSub = null;
  23. handledResult.subscribe(subscriber);
  24. }
  25. });
  26. }
  27. //# sourceMappingURL=catchError.js.map