Skip to content

Instantly share code, notes, and snippets.

@chanonroy
Last active November 1, 2020 12:45
Show Gist options
  • Select an option

  • Save chanonroy/f9c85273d31c949c661e6725aede6d68 to your computer and use it in GitHub Desktop.

Select an option

Save chanonroy/f9c85273d31c949c661e6725aede6d68 to your computer and use it in GitHub Desktop.
export const waitFor = async (cb: any) => {
let c = 0
async function f() {
try {
await cb()
} catch (error) {
if (c < 9) {
c += 1
setTimeout(f, 500)
}
}
}
await f()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment