-
-
Save getify/cb8079dcd11e1d2080bf3f8036aee2b3 to your computer and use it in GitHub Desktop.
waitForEvent(..) -- promisified event listener
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 waitForEvent(elem,evtName) { | |
return new Promise(function c(resolve){ | |
elem.addEventListener(evtName,function onEvent(evt){ | |
elem.removeEventListener(evtName,onEvent,false); | |
resolve(evt); | |
},false); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't use async/await on this...