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.

defaultIfEmpty.js 914B

123456789101112131415161718192021222324252627282930
  1. import { Subscriber } from '../Subscriber';
  2. export function defaultIfEmpty(defaultValue = null) {
  3. return (source) => source.lift(new DefaultIfEmptyOperator(defaultValue));
  4. }
  5. class DefaultIfEmptyOperator {
  6. constructor(defaultValue) {
  7. this.defaultValue = defaultValue;
  8. }
  9. call(subscriber, source) {
  10. return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
  11. }
  12. }
  13. class DefaultIfEmptySubscriber extends Subscriber {
  14. constructor(destination, defaultValue) {
  15. super(destination);
  16. this.defaultValue = defaultValue;
  17. this.isEmpty = true;
  18. }
  19. _next(value) {
  20. this.isEmpty = false;
  21. this.destination.next(value);
  22. }
  23. _complete() {
  24. if (this.isEmpty) {
  25. this.destination.next(this.defaultValue);
  26. }
  27. this.destination.complete();
  28. }
  29. }
  30. //# sourceMappingURL=defaultIfEmpty.js.map