Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 47x 47x 47x 47x 1427x 6x 5x 1x 2x 1x 1x | import { PollProps, poll } from '@cardano-sdk/util-rxjs';
import { ProviderError, ProviderFailure } from '@cardano-sdk/core';
import { catchError } from 'rxjs';
export type PollProviderProps<T> = Omit<PollProps<T>, 'retryBackoffConfig'> & {
retryBackoffConfig: Omit<PollProps<T>['retryBackoffConfig'], 'shouldRetry'>;
};
export const pollProvider = <T>(props: PollProviderProps<T>) =>
poll({
...props,
retryBackoffConfig: {
...props.retryBackoffConfig,
shouldRetry: (error) => {
if (error instanceof ProviderError) {
return ![ProviderFailure.NotImplemented, ProviderFailure.BadRequest].includes(error.reason);
}
return false;
}
}
}).pipe(
catchError((error) => {
if (error instanceof ProviderError) {
throw error;
}
throw new ProviderError(ProviderFailure.Unknown, error);
})
);
|