Simple Listen
Small utility for adding event listeners that returns the listener for easy unsubscribing
Installation
$ npm install simple-listen
API
listen(el, events, cb, capture, context)
el
- the DOM element you are attaching events toevents
- [string|array[string]] - the event types to attachcb
- [function] - the function to call when event firescapture
- [boolean] -false
- use capturecontext
- [object] -null
- the context applied tocb
Example
; const el = document;const callback = console; const myListener = ;; // remove event listener // Multiple listenersconst listeners = ;listeners;listeners;listeners;listeners;listeners; // quickly remove the event listenerslisteners;
License
Modified BSD