Skip to content

Instantly share code, notes, and snippets.

@rimiti
Last active October 18, 2017 09:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rimiti/bc8cda0baeb9bc615fe92af33b19b3ca to your computer and use it in GitHub Desktop.
Save rimiti/bc8cda0baeb9bc615fe92af33b19b3ca to your computer and use it in GitHub Desktop.
Add delay (ms) between promises

If you wants to add a delay between two promise:

/**
 * @description Add delay (ms) between promises
 * @param delay
 * @return {Promise}
 */
wait(delay) {
  wait(delay) {
    return new Promise((resolve) => {
      setTimeout(() => resolve(), delay)
    })
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment