innerSubscribe.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /** PURE_IMPORTS_START tslib,_Subscriber,_Observable,_util_subscribeTo PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { Subscriber } from './Subscriber';
  4. import { Observable } from './Observable';
  5. import { subscribeTo } from './util/subscribeTo';
  6. var SimpleInnerSubscriber = /*@__PURE__*/ (function (_super) {
  7. tslib_1.__extends(SimpleInnerSubscriber, _super);
  8. function SimpleInnerSubscriber(parent) {
  9. var _this = _super.call(this) || this;
  10. _this.parent = parent;
  11. return _this;
  12. }
  13. SimpleInnerSubscriber.prototype._next = function (value) {
  14. this.parent.notifyNext(value);
  15. };
  16. SimpleInnerSubscriber.prototype._error = function (error) {
  17. this.parent.notifyError(error);
  18. this.unsubscribe();
  19. };
  20. SimpleInnerSubscriber.prototype._complete = function () {
  21. this.parent.notifyComplete();
  22. this.unsubscribe();
  23. };
  24. return SimpleInnerSubscriber;
  25. }(Subscriber));
  26. export { SimpleInnerSubscriber };
  27. var ComplexInnerSubscriber = /*@__PURE__*/ (function (_super) {
  28. tslib_1.__extends(ComplexInnerSubscriber, _super);
  29. function ComplexInnerSubscriber(parent, outerValue, outerIndex) {
  30. var _this = _super.call(this) || this;
  31. _this.parent = parent;
  32. _this.outerValue = outerValue;
  33. _this.outerIndex = outerIndex;
  34. return _this;
  35. }
  36. ComplexInnerSubscriber.prototype._next = function (value) {
  37. this.parent.notifyNext(this.outerValue, value, this.outerIndex, this);
  38. };
  39. ComplexInnerSubscriber.prototype._error = function (error) {
  40. this.parent.notifyError(error);
  41. this.unsubscribe();
  42. };
  43. ComplexInnerSubscriber.prototype._complete = function () {
  44. this.parent.notifyComplete(this);
  45. this.unsubscribe();
  46. };
  47. return ComplexInnerSubscriber;
  48. }(Subscriber));
  49. export { ComplexInnerSubscriber };
  50. var SimpleOuterSubscriber = /*@__PURE__*/ (function (_super) {
  51. tslib_1.__extends(SimpleOuterSubscriber, _super);
  52. function SimpleOuterSubscriber() {
  53. return _super !== null && _super.apply(this, arguments) || this;
  54. }
  55. SimpleOuterSubscriber.prototype.notifyNext = function (innerValue) {
  56. this.destination.next(innerValue);
  57. };
  58. SimpleOuterSubscriber.prototype.notifyError = function (err) {
  59. this.destination.error(err);
  60. };
  61. SimpleOuterSubscriber.prototype.notifyComplete = function () {
  62. this.destination.complete();
  63. };
  64. return SimpleOuterSubscriber;
  65. }(Subscriber));
  66. export { SimpleOuterSubscriber };
  67. var ComplexOuterSubscriber = /*@__PURE__*/ (function (_super) {
  68. tslib_1.__extends(ComplexOuterSubscriber, _super);
  69. function ComplexOuterSubscriber() {
  70. return _super !== null && _super.apply(this, arguments) || this;
  71. }
  72. ComplexOuterSubscriber.prototype.notifyNext = function (_outerValue, innerValue, _outerIndex, _innerSub) {
  73. this.destination.next(innerValue);
  74. };
  75. ComplexOuterSubscriber.prototype.notifyError = function (error) {
  76. this.destination.error(error);
  77. };
  78. ComplexOuterSubscriber.prototype.notifyComplete = function (_innerSub) {
  79. this.destination.complete();
  80. };
  81. return ComplexOuterSubscriber;
  82. }(Subscriber));
  83. export { ComplexOuterSubscriber };
  84. export function innerSubscribe(result, innerSubscriber) {
  85. if (innerSubscriber.closed) {
  86. return undefined;
  87. }
  88. if (result instanceof Observable) {
  89. return result.subscribe(innerSubscriber);
  90. }
  91. var subscription;
  92. try {
  93. subscription = subscribeTo(result)(innerSubscriber);
  94. }
  95. catch (error) {
  96. innerSubscriber.error(error);
  97. }
  98. return subscription;
  99. }
  100. //# sourceMappingURL=innerSubscribe.js.map