Skip to content

Instantly share code, notes, and snippets.

View sagirk's full-sized avatar
🪄

Sagir Khan sagirk

🪄
View GitHub Profile
@sagirk
sagirk / pollWithExponentialBackoff.ts
Last active May 6, 2021 06:43
Poll without hammering the server – use the exponential backoff algorithm to space out retries
/**
* A configuration object for `pollWithExponentialBackoff`
*/
interface IPollOptions {
/**
* A callback that will be run on every poll attempt
*/
executor: () => Promise<any>
/**
* A callback that will be run after each poll attempt to check if further