catchError.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.catchError = void 0;
  4. var innerFrom_1 = require("../observable/innerFrom");
  5. var OperatorSubscriber_1 = require("./OperatorSubscriber");
  6. var lift_1 = require("../util/lift");
  7. function catchError(selector) {
  8. return lift_1.operate(function (source, subscriber) {
  9. var innerSub = null;
  10. var syncUnsub = false;
  11. var handledResult;
  12. innerSub = source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
  13. handledResult = innerFrom_1.innerFrom(selector(err, catchError(selector)(source)));
  14. if (innerSub) {
  15. innerSub.unsubscribe();
  16. innerSub = null;
  17. handledResult.subscribe(subscriber);
  18. }
  19. else {
  20. syncUnsub = true;
  21. }
  22. }));
  23. if (syncUnsub) {
  24. innerSub.unsubscribe();
  25. innerSub = null;
  26. handledResult.subscribe(subscriber);
  27. }
  28. });
  29. }
  30. exports.catchError = catchError;
  31. //# sourceMappingURL=catchError.js.map