Skip to content

Instantly share code, notes, and snippets.

@didierbrun
Created January 16, 2024 19:35
Show Gist options
  • Save didierbrun/50c187ef70aa316456c3985e90d2cfca to your computer and use it in GitHub Desktop.
Save didierbrun/50c187ef70aa316456c3985e90d2cfca to your computer and use it in GitHub Desktop.
Suspense
const suspense = (f, t) => setTimeout(f, t * 1000)
const message = () => {
let t = 0
suspense(() => {
console.log("Je veux que créer...")
}, t)
suspense(() => {
console.log("...un peu de...")
}, t+1)
suspense(() => {
console.log("... Suspense !")
}, t+2)
}
const tambour = () => {
let i = 0
while(++i<10){
suspense(() => {
console.log("tadam...")
}, i * .2)
}
}
message()
tambour()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment