Created
April 23, 2016 16:05
-
-
Save ramonvictor/67b894b7d07e1ef777f5432602cd8112 to your computer and use it in GitHub Desktop.
Fancy setTimeout wrapper using native Promise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wait = function(ms) { | |
ms = ms || 500; | |
return new Promise(function(resolve, reject){ | |
window.setTimeout(function() { | |
resolve(); | |
}, ms); | |
}); | |
}; | |
// USAGE | |
// --------- | |
wait(500).then(function() { | |
// Do stuff after 500ms | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment