Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcello3d/node-listenable
simple event emitter
https://github.com/marcello3d/node-listenable
Last synced: 15 days ago
JSON representation
simple event emitter
- Host: GitHub
- URL: https://github.com/marcello3d/node-listenable
- Owner: marcello3d
- License: zlib
- Created: 2013-10-25T17:21:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-25T17:50:14.000Z (about 11 years ago)
- Last Synced: 2024-10-18T15:06:05.789Z (29 days ago)
- Language: JavaScript
- Size: 102 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
node-listenable
===============
listenable is a super simple event emitterInstall
-------npm install listenable
API
---```js
var listenable = new Listenable // new instance// add event listener
listenable.on(eventName, fn)// add event listener that only triggers once
listenable.once(eventName, fn)// remove specific event listener (will remove all listeners that === fn)
listenable.off(eventName, fn)// remove all listeners for a name
listenable.off(eventName)// trigger an event (additional arguments are passed to the listeners)
listenable.emit(eventName[, args...])// get listeners for an event
listenable.listeners.eventName // null or potentially empty Array of listeners
```Examples
--------
```js
var Listenable = require('listenable')var listenable = new Listenable
listenable.on('foo', function(arg) {
console.log("foo "+arg+" just happened!")
})listenable.emit('foo', 1)
listenable.off('foo')
listenable.emit('foo', 2)```
License
-------
listenable is open source software under the [zlib license][LICENSE].