Dan Stroot Headshot

Wait

1 min read

Published

  
  
       
  
  export function timeout(delay: number) {
    return new Promise( res => setTimeout(res, delay) );
}

Context

Sometimes when you are building something you want to see how it works with a little delay. I use this for playing with, or testing, React suspense.

Usage

  
  
       
  
  import { timeout } from '../lib/timeout'

await timeout(1000) //for 1 sec delay