frontend/.pnpm-store/v3/files/38/ec0428bc171da41ed533cc9d67abf76253709c99e87ea166b3c48e6fb704a94f226f3a0e88b09887bf5361036a3462add4df4fb772e7416ba159d8108d00c8

33 lines
961 B
Plaintext

import { Subscriber } from '../Subscriber';
export function retry(count = -1) {
return (source) => source.lift(new RetryOperator(count, source));
}
class RetryOperator {
constructor(count, source) {
this.count = count;
this.source = source;
}
call(subscriber, source) {
return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
}
}
class RetrySubscriber extends Subscriber {
constructor(destination, count, source) {
super(destination);
this.count = count;
this.source = source;
}
error(err) {
if (!this.isStopped) {
const { source, count } = this;
if (count === 0) {
return super.error(err);
}
else if (count > -1) {
this.count = count - 1;
}
source.subscribe(this._unsubscribeAndRecycle());
}
}
}
//# sourceMappingURL=retry.js.map