dom-event-utils
Very small library that makes working with DOM event emitters API a little easier to work with. These are all common utilities that I find myself reaching for, regardless of the framework I'm in.
Methods
eventToPromise
- convert an event to a promise that resolves once it's called.
For example:
; { const popup = window; return ; //timeout is optional. If reached, it'll reject the promise}
on
- just like addEventListener
, but returns an unsubscribe function.
; const off = ;//...later, somewhere else...;
once
- only called once and then unsubscribed from the event source
; ;