ES6 await for a button click
1 min readDec 23, 2019
The simplest way to await for a button click event. Some stackoverflow answers suggest to have a timeout and check for the value of a global variable. But this doesn’t need to be so complicated. Here is a minimal version that I’ve found working:
await new Promise((resulve, reject) => {
button.onclick = () => { resolve(); };
}
Simple but handy, isn’t it?