Socket
Socket
Sign inDemoInstall

custom-event-js

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    custom-event-js

Custom Event Dispatcher


Version published
Weekly downloads
37
decreased by-28.85%
Maintainers
1
Install size
6.39 kB
Created
Weekly downloads
 

Readme

Source

Custom Event Dispatcher Twitter URL

MIT Licence npm version Known Vulnerabilities

The Custom Event Dispatcher provides the ability to communicate inside your application by dispatching events and listening to them. It also runs polyfill for Internet Explorer 9 and higher. What is the CustomEvent interface you may find here.

Custom Event Dispatcher works in all popular browsers, including Internet Explorer 9 and higher.

Install

npm

npm install --save custom-event-js

yarn

yarn add custom-event-js --save

Example

import CustomEvent from 'custom-event-js'

// Listen event 'SHOW_NAME'
CustomEvent.on('SHOW_NAME', (data) => {
    console.log(data.detail) // { name: 'GitHub' }
})

// Dispatch event 'SHOW_NAME' with data
CustomEvent.dispatch('SHOW_NAME', { name: 'GitHub' })

// Remove event listener
CustomEvent.off('SHOW_NAME')

API

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

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

  • off(eventName) remove event listener

Contributing

Any contributions you make are greatly appreciated.

Please read the Contributions Guidelines before submitting a PR.

License

MIT © Vasyl Stokolosa

Keywords

FAQs

Last updated on 19 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc