Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

catchError.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. }
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var OuterSubscriber_1 = require("../OuterSubscriber");
  17. var InnerSubscriber_1 = require("../InnerSubscriber");
  18. var subscribeToResult_1 = require("../util/subscribeToResult");
  19. function catchError(selector) {
  20. return function catchErrorOperatorFunction(source) {
  21. var operator = new CatchOperator(selector);
  22. var caught = source.lift(operator);
  23. return (operator.caught = caught);
  24. };
  25. }
  26. exports.catchError = catchError;
  27. var CatchOperator = (function () {
  28. function CatchOperator(selector) {
  29. this.selector = selector;
  30. }
  31. CatchOperator.prototype.call = function (subscriber, source) {
  32. return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
  33. };
  34. return CatchOperator;
  35. }());
  36. var CatchSubscriber = (function (_super) {
  37. __extends(CatchSubscriber, _super);
  38. function CatchSubscriber(destination, selector, caught) {
  39. var _this = _super.call(this, destination) || this;
  40. _this.selector = selector;
  41. _this.caught = caught;
  42. return _this;
  43. }
  44. CatchSubscriber.prototype.error = function (err) {
  45. if (!this.isStopped) {
  46. var result = void 0;
  47. try {
  48. result = this.selector(err, this.caught);
  49. }
  50. catch (err2) {
  51. _super.prototype.error.call(this, err2);
  52. return;
  53. }
  54. this._unsubscribeAndRecycle();
  55. var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
  56. this.add(innerSubscriber);
  57. subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
  58. }
  59. };
  60. return CatchSubscriber;
  61. }(OuterSubscriber_1.OuterSubscriber));
  62. //# sourceMappingURL=catchError.js.map