tp-register-listener
Intro
Built to use modern event listener options register a listener and return a method to remove the listener.
Example
; const handler = { // do something};const body = documentbody;const unReg = ;// remove this listener;
Install
API
registerListener(ele, eventName, callback, opts, unRegisterListenersCollection)
Returns a unRegister function to remove the listener.
@param {HTMLElement} ele
- Elements to binding event;@param {string} eventName
- The event name;@param {EventListener} callback
- The event listener;@param {EventListenerOptions} [opts={}]
- The event listener options;@param {Function[]} [unRegisterListenersCollection]
- The collections of unRegister listeners.
const unRegisterListenersCollection = const handler = { // empty}const ele = documentbody // remove all listeners.unRegisterListenersCollection
registerListener._uiEvtOpts
@return {boolean}
- Return true when the environment support "passive"EventListenerOptions
ifregisterListener as any._uiEvtOpts
Development
npm t
: Run test suitenpm start
: Runnpm run build
in watch modenpm run test:watch
: Run test suite in interactive watch modenpm run test:prod
: Run linting and generate coveragenpm run build
: Generate bundles and typings, create docsnpm run lint
: Lints codenpm run commit
: Commit using conventional commit style (husky will tell you to use it if you haven't 😉)
License
MIT