Created
June 3, 2018 04:31
-
-
Save qswitcher/5b715b39d8a35bd9c134ce539ea09644 to your computer and use it in GitHub Desktop.
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
const wait = (wrapper, predicate, timeout = 10) => { | |
return new Promise((resolve, reject) => { | |
if (predicate(wrapper)) { | |
return resolve(true); | |
} | |
setTimeout(() => { | |
wrapper.update(); | |
return predicate(wrapper) ? resolve(true) : reject(new Error('Timeout expired')); | |
}, timeout); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment