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.

exhaustMap.js 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /** PURE_IMPORTS_START tslib,_OuterSubscriber,_InnerSubscriber,_util_subscribeToResult,_map,_observable_from PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { OuterSubscriber } from '../OuterSubscriber';
  4. import { InnerSubscriber } from '../InnerSubscriber';
  5. import { subscribeToResult } from '../util/subscribeToResult';
  6. import { map } from './map';
  7. import { from } from '../observable/from';
  8. export function exhaustMap(project, resultSelector) {
  9. if (resultSelector) {
  10. return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
  11. }
  12. return function (source) {
  13. return source.lift(new ExhaustMapOperator(project));
  14. };
  15. }
  16. var ExhaustMapOperator = /*@__PURE__*/ (function () {
  17. function ExhaustMapOperator(project) {
  18. this.project = project;
  19. }
  20. ExhaustMapOperator.prototype.call = function (subscriber, source) {
  21. return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
  22. };
  23. return ExhaustMapOperator;
  24. }());
  25. var ExhaustMapSubscriber = /*@__PURE__*/ (function (_super) {
  26. tslib_1.__extends(ExhaustMapSubscriber, _super);
  27. function ExhaustMapSubscriber(destination, project) {
  28. var _this = _super.call(this, destination) || this;
  29. _this.project = project;
  30. _this.hasSubscription = false;
  31. _this.hasCompleted = false;
  32. _this.index = 0;
  33. return _this;
  34. }
  35. ExhaustMapSubscriber.prototype._next = function (value) {
  36. if (!this.hasSubscription) {
  37. this.tryNext(value);
  38. }
  39. };
  40. ExhaustMapSubscriber.prototype.tryNext = function (value) {
  41. var result;
  42. var index = this.index++;
  43. try {
  44. result = this.project(value, index);
  45. }
  46. catch (err) {
  47. this.destination.error(err);
  48. return;
  49. }
  50. this.hasSubscription = true;
  51. this._innerSub(result, value, index);
  52. };
  53. ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
  54. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  55. var destination = this.destination;
  56. destination.add(innerSubscriber);
  57. subscribeToResult(this, result, value, index, innerSubscriber);
  58. };
  59. ExhaustMapSubscriber.prototype._complete = function () {
  60. this.hasCompleted = true;
  61. if (!this.hasSubscription) {
  62. this.destination.complete();
  63. }
  64. this.unsubscribe();
  65. };
  66. ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  67. this.destination.next(innerValue);
  68. };
  69. ExhaustMapSubscriber.prototype.notifyError = function (err) {
  70. this.destination.error(err);
  71. };
  72. ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
  73. var destination = this.destination;
  74. destination.remove(innerSub);
  75. this.hasSubscription = false;
  76. if (this.hasCompleted) {
  77. this.destination.complete();
  78. }
  79. };
  80. return ExhaustMapSubscriber;
  81. }(OuterSubscriber));
  82. //# sourceMappingURL=exhaustMap.js.map