Created
January 9, 2017 07:04
-
-
Save shussekaido/afb93fe027d671023be9f5a5886e9d7e to your computer and use it in GitHub Desktop.
Use Promise to wait until polled condition is satisfied
This file contains 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
function ensureFooIsSet() { | |
return new Promise(function (resolve, reject) { | |
(function waitForFoo(){ | |
if (lib.foo) return resolve(); | |
setTimeout(waitForFoo, 30); | |
})(); | |
}); | |
} | |
// http://stackoverflow.com/questions/30505960/use-promise-to-wait-until-polled-condition-is-satisfied |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment