vite-plugin-shopify-theme-islands
Version:
Vite plugin for island architecture in Shopify themes
28 lines (27 loc) • 1.06 kB
TypeScript
export interface RetryPlatform {
setTimeout(fn: () => void, delay: number): ReturnType<typeof setTimeout>;
clearTimeout(timer: ReturnType<typeof setTimeout>): void;
}
export interface RetrySchedulerOptions {
retries: number;
retryDelay: number;
platform?: RetryPlatform;
}
export interface RetryScheduler {
/** Returns the attempt number a settle would resolve to, without mutating state. */
attemptOf(tag: string): number;
/**
* Records a failed attempt. If retries are not exhausted, schedules `retry`
* via the platform timer with exponential backoff. Returns the attempt number
* just used and whether another retry is queued.
*/
scheduleRetry(tag: string, retry: () => void): {
willRetry: boolean;
attempt: number;
};
/** Cancel any pending retry timer and forget the attempt count for one tag. */
cancel(tag: string): void;
/** Cancel everything. */
cancelAll(): void;
}
export declare function createRetryScheduler(options: RetrySchedulerOptions): RetryScheduler;