clearall 🧹
Clear all event listeners at once.
Install
npm install clearall
Examples
Basic
const clearAll =
Disposable Class
{ this_clearEvents = } { this } /* ... */
React hook
{ const ref = /* ... */}
API
add(listenable, eventName, listener, ...params)
Add an event listener and return a clearAll()
function.
clearAll()
Remove all added event listeners.
clearAll.add(listenable, eventName, listener, ...params)
Add an event listener to the same clearAll context.
Tips
Type Error for window custom event in typescript.
// ❌ erroraddwindow, 'user_custom_event',
For convenience, there are strong type constraints for some global objects. But sometimes this gets in the way.
any
can cancel this type constraint.
// ✔️ ok.addwindow as any, 'user_custom_event',
License
MIT