https://github.com/boneskull/eventemittable
A composable EventEmitter for Stampit v3
https://github.com/boneskull/eventemittable
composition emitter eventemitter events stamp stampit
Last synced: 3 months ago
JSON representation
A composable EventEmitter for Stampit v3
- Host: GitHub
- URL: https://github.com/boneskull/eventemittable
- Owner: boneskull
- License: other
- Archived: true
- Created: 2017-04-29T07:54:09.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-30T08:34:36.000Z (about 8 years ago)
- Last Synced: 2024-10-29T22:37:19.749Z (8 months ago)
- Topics: composition, emitter, eventemitter, events, stamp, stampit
- Language: JavaScript
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eventemittable
> A composable `EventEmitter` for Stampit v3
## Install
```bash
$ npm install stampit eventemittable --save
```[Stampit](https://npm.im/stampit) v3 or greater is a peer dependency of this module.
## Usage
```js
import EventEmittable from 'eventemittable';
import stampit from 'stampit';// some stamp
const User = stampit.init((opts, {instance}) => {
if (opts.name) {
instance.name = opts.name;
}
})
.props({
name: {
first: "(unnamed)",
last: "(unnamed)"
}
});// an emittable version of some stamp
const EmittableUser = User.compose(EventEmittable);// elsewhere...
const user = EmittableUser({name: {first: 'Guy', last: 'Fieri'}});
user.on('name', name => {
console.log(`${name.first} ${name.last}`);
});
user.emit('name', user.name); // 'Guy Fieri'
```## Notes
Apologies to [koresar](https://github.com/koresar). :D
## License
© 2017 [Christopher Hiller](https://boneskull.com). Licensed Apache-2.0.