OperatorSubscriber.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { __extends } from "tslib";
  2. import { Subscriber } from '../Subscriber';
  3. export function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
  4. return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
  5. }
  6. var OperatorSubscriber = (function (_super) {
  7. __extends(OperatorSubscriber, _super);
  8. function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
  9. var _this = _super.call(this, destination) || this;
  10. _this.onFinalize = onFinalize;
  11. _this.shouldUnsubscribe = shouldUnsubscribe;
  12. _this._next = onNext
  13. ? function (value) {
  14. try {
  15. onNext(value);
  16. }
  17. catch (err) {
  18. destination.error(err);
  19. }
  20. }
  21. : _super.prototype._next;
  22. _this._error = onError
  23. ? function (err) {
  24. try {
  25. onError(err);
  26. }
  27. catch (err) {
  28. destination.error(err);
  29. }
  30. finally {
  31. this.unsubscribe();
  32. }
  33. }
  34. : _super.prototype._error;
  35. _this._complete = onComplete
  36. ? function () {
  37. try {
  38. onComplete();
  39. }
  40. catch (err) {
  41. destination.error(err);
  42. }
  43. finally {
  44. this.unsubscribe();
  45. }
  46. }
  47. : _super.prototype._complete;
  48. return _this;
  49. }
  50. OperatorSubscriber.prototype.unsubscribe = function () {
  51. var _a;
  52. if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
  53. var closed_1 = this.closed;
  54. _super.prototype.unsubscribe.call(this);
  55. !closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
  56. }
  57. };
  58. return OperatorSubscriber;
  59. }(Subscriber));
  60. export { OperatorSubscriber };
  61. //# sourceMappingURL=OperatorSubscriber.js.map