snorkel
v1.0.0
Published
Event Dispatcher
Downloads
3
Readme
Snorkel
:swimmer: Event Dispatcher
Usage
import EventDispatcher from 'snorkel'
// Listen for an event
EventDispatcher.on('welcome', (data) => {
console.log('The welcome event happened with ' + data)
})
function isReady {
console.log('The thing is ready')
}
// Listen for an event only once
EventDispatcher.once('ready', isReady)
// Emit an event
EventDispatcher.emit('welcome', 'emit', 'as', 'many', 'params', 'as', 'you', 'like')
// Remove event listener
EventDispatcher.off('ready', isReady)
// Clear all event dispatchers
EventDispatcher.clear()