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.

onErrorResumeNext.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { from } from '../observable/from';
  2. import { isArray } from '../util/isArray';
  3. import { OuterSubscriber } from '../OuterSubscriber';
  4. import { InnerSubscriber } from '../InnerSubscriber';
  5. import { subscribeToResult } from '../util/subscribeToResult';
  6. export function onErrorResumeNext(...nextSources) {
  7. if (nextSources.length === 1 && isArray(nextSources[0])) {
  8. nextSources = nextSources[0];
  9. }
  10. return (source) => source.lift(new OnErrorResumeNextOperator(nextSources));
  11. }
  12. export function onErrorResumeNextStatic(...nextSources) {
  13. let source = null;
  14. if (nextSources.length === 1 && isArray(nextSources[0])) {
  15. nextSources = nextSources[0];
  16. }
  17. source = nextSources.shift();
  18. return from(source, null).lift(new OnErrorResumeNextOperator(nextSources));
  19. }
  20. class OnErrorResumeNextOperator {
  21. constructor(nextSources) {
  22. this.nextSources = nextSources;
  23. }
  24. call(subscriber, source) {
  25. return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
  26. }
  27. }
  28. class OnErrorResumeNextSubscriber extends OuterSubscriber {
  29. constructor(destination, nextSources) {
  30. super(destination);
  31. this.destination = destination;
  32. this.nextSources = nextSources;
  33. }
  34. notifyError(error, innerSub) {
  35. this.subscribeToNextSource();
  36. }
  37. notifyComplete(innerSub) {
  38. this.subscribeToNextSource();
  39. }
  40. _error(err) {
  41. this.subscribeToNextSource();
  42. this.unsubscribe();
  43. }
  44. _complete() {
  45. this.subscribeToNextSource();
  46. this.unsubscribe();
  47. }
  48. subscribeToNextSource() {
  49. const next = this.nextSources.shift();
  50. if (!!next) {
  51. const innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  52. const destination = this.destination;
  53. destination.add(innerSubscriber);
  54. subscribeToResult(this, next, undefined, undefined, innerSubscriber);
  55. }
  56. else {
  57. this.destination.complete();
  58. }
  59. }
  60. }
  61. //# sourceMappingURL=onErrorResumeNext.js.map