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.

shareReplay.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var ReplaySubject_1 = require("../ReplaySubject");
  4. function shareReplay(bufferSize, windowTime, scheduler) {
  5. if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
  6. if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
  7. return function (source) { return source.lift(shareReplayOperator(bufferSize, windowTime, scheduler)); };
  8. }
  9. exports.shareReplay = shareReplay;
  10. function shareReplayOperator(bufferSize, windowTime, scheduler) {
  11. var subject;
  12. var refCount = 0;
  13. var subscription;
  14. var hasError = false;
  15. var isComplete = false;
  16. return function shareReplayOperation(source) {
  17. refCount++;
  18. if (!subject || hasError) {
  19. hasError = false;
  20. subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
  21. subscription = source.subscribe({
  22. next: function (value) { subject.next(value); },
  23. error: function (err) {
  24. hasError = true;
  25. subject.error(err);
  26. },
  27. complete: function () {
  28. isComplete = true;
  29. subject.complete();
  30. },
  31. });
  32. }
  33. var innerSub = subject.subscribe(this);
  34. return function () {
  35. refCount--;
  36. innerSub.unsubscribe();
  37. if (subscription && refCount === 0 && isComplete) {
  38. subscription.unsubscribe();
  39. }
  40. };
  41. };
  42. }
  43. //# sourceMappingURL=shareReplay.js.map