https://github.com/capaj/weakee
Weakmaps powered lightweight event emitter(this one should not leak)
https://github.com/capaj/weakee
Last synced: about 1 year ago
JSON representation
Weakmaps powered lightweight event emitter(this one should not leak)
- Host: GitHub
- URL: https://github.com/capaj/weakee
- Owner: capaj
- License: mit
- Created: 2015-09-24T00:29:15.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-01-23T20:17:38.000Z (over 10 years ago)
- Last Synced: 2024-04-09T21:10:37.517Z (about 2 years ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# weakee
Weakmaps powered lightweight event emitter(this one should not leak)
Written in ES6.
Tests have a babel hook, but in order to use this in your node.js app, you will have to use babel register hook.
On the frontend, JSPM handles it for you.
## Install
```shell
npm i weakee -S
#or on the frontend
jspm i npm:weakee
```
### Usage
```javascript
import Emitter from 'weakee'
class UserClass extends Emitter {
constructor() {
super()
}
}
var inst = new UserClass()
inst.emit('myEvent', whatever, params)
inst.on('myEvent', (whatever, params)=>{
//runs until you call .off()
})
inst.once('myEvent', (whatever, params)=>{
//runs once
})
inst.off('myEvent', handlerFunction) //removes the even handler
```