Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Event dispatcher based on the CustomEvent interface (works on browser)

License

NotificationsYou must be signed in to change notification settings

shystruk/custom-event-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT Licencenpm versionKnown Vulnerabilities

The Custom Event Dispatcher provides the ability to communicate inside your application by dispatching events and listening to them. What is the CustomEvent interface you may findhere.

Custom Event Dispatcher works in all popular browsers

Install

npm

npm install --save custom-event-js

yarn

yarn add custom-event-js --save

Example

importCustomEventfrom'custom-event-js'// Listen event 'SHOW_NAME'CustomEvent.on('SHOW_NAME',(data)=>{console.log(data.detail)// { name: 'GitHub' }})// Dispatch event 'SHOW_NAME' with dataCustomEvent.dispatch('SHOW_NAME',{name:'GitHub'})// Remove event listenerCustomEvent.off('SHOW_NAME')// Remove a specific callback from event listenerCustomEvent.off('SHOW_NAME',callback)

API

  • on(eventName, callback) add an appropriate event listener. When event gets fired callback will be called withdetail argument

  • dispatch(eventName, detail) dispatch event to all event listeners

  • off(eventName) remove all event listeners for the event

  • off(eventName, callback) remove a specific event listener for the event

Contributing

Any contributions you makeare greatly appreciated.

Please read theContributions Guidelines before submitting a PR.

License

MIT ©Vasyl Stokolosa


[8]ページ先頭

©2009-2025 Movatter.jp