Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

retry.js 961B

123456789101112131415161718192021222324252627282930313233
  1. import { Subscriber } from '../Subscriber';
  2. export function retry(count = -1) {
  3. return (source) => source.lift(new RetryOperator(count, source));
  4. }
  5. class RetryOperator {
  6. constructor(count, source) {
  7. this.count = count;
  8. this.source = source;
  9. }
  10. call(subscriber, source) {
  11. return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
  12. }
  13. }
  14. class RetrySubscriber extends Subscriber {
  15. constructor(destination, count, source) {
  16. super(destination);
  17. this.count = count;
  18. this.source = source;
  19. }
  20. error(err) {
  21. if (!this.isStopped) {
  22. const { source, count } = this;
  23. if (count === 0) {
  24. return super.error(err);
  25. }
  26. else if (count > -1) {
  27. this.count = count - 1;
  28. }
  29. source.subscribe(this._unsubscribeAndRecycle());
  30. }
  31. }
  32. }
  33. //# sourceMappingURL=retry.js.map