Skip to content

Instantly share code, notes, and snippets.

@igolka97
Created August 4, 2024 16:39
Show Gist options
  • Save igolka97/55c5a0952fa260976ace13208512debd to your computer and use it in GitHub Desktop.
Save igolka97/55c5a0952fa260976ace13208512debd to your computer and use it in GitHub Desktop.
Run promise ticking like setInterval but async
async function startTick (fn: () => Promise<any>, timeoutMs: number = 5000) {
fn().then(() => {
setTimeout(() => {
startTick(fn, timeoutMs)
}, timeoutMs)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment