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.

exhaust.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { OuterSubscriber } from '../OuterSubscriber';
  2. import { subscribeToResult } from '../util/subscribeToResult';
  3. export function exhaust() {
  4. return (source) => source.lift(new SwitchFirstOperator());
  5. }
  6. class SwitchFirstOperator {
  7. call(subscriber, source) {
  8. return source.subscribe(new SwitchFirstSubscriber(subscriber));
  9. }
  10. }
  11. class SwitchFirstSubscriber extends OuterSubscriber {
  12. constructor(destination) {
  13. super(destination);
  14. this.hasCompleted = false;
  15. this.hasSubscription = false;
  16. }
  17. _next(value) {
  18. if (!this.hasSubscription) {
  19. this.hasSubscription = true;
  20. this.add(subscribeToResult(this, value));
  21. }
  22. }
  23. _complete() {
  24. this.hasCompleted = true;
  25. if (!this.hasSubscription) {
  26. this.destination.complete();
  27. }
  28. }
  29. notifyComplete(innerSub) {
  30. this.remove(innerSub);
  31. this.hasSubscription = false;
  32. if (this.hasCompleted) {
  33. this.destination.complete();
  34. }
  35. }
  36. }
  37. //# sourceMappingURL=exhaust.js.map