1234567891011 |
- const domEventPromise = (element, eventName) => {
- return new Promise((resolve, reject) => {
- const handler = event => {
- resolve(event);
- element.removeEventListener(eventName, handler);
- }
- element.addEventListener(eventName, handler);
- });
- }
- domEventPromise(button, 'click').then( e => console.log('event click happens', e))
|