observable-eventlisteners
v1.1.0
Published
**Observable is a useful node.js plugin to add event listeners that can be called upon later.**
Downloads
3
Readme
Observable Event Listeners
What is Observable?
Observable is a useful node.js plugin to add event listeners that can be called upon later.
Setting up:
npm i observable-eventlisteners --save
Importing:
const { Observable } = require('observable-eventlisteners')
Preparation:
var observable = new Observable();
Commands:
Listening for Events:
observable.on('your event', (data) => {console.log(data})
Firing Events:
observable.fire('your event', {message: 'hello'})
Output: {message: 'hello'}
or
observable.fireEvent('your event', {message: 'hello world'})
Output: {message: 'hello world'}
or
observable.send('your event', {message: 'Hello World!'})
Output: {message: 'Hello World!'}