Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jesstelford/reflux-triggerable-mixin
Reflux stores mixin adding `triggerable` syntax similar to `listenable`.
https://github.com/jesstelford/reflux-triggerable-mixin
Last synced: about 1 month ago
JSON representation
Reflux stores mixin adding `triggerable` syntax similar to `listenable`.
- Host: GitHub
- URL: https://github.com/jesstelford/reflux-triggerable-mixin
- Owner: jesstelford
- Created: 2015-04-19T21:49:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-19T05:49:50.000Z (about 9 years ago)
- Last Synced: 2024-12-02T02:13:27.401Z (about 2 months ago)
- Language: JavaScript
- Size: 138 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Reflux Triggerable Mixin
Mixin for [reflux](https://www.npmjs.com/packages/reflux) stores to enable quick
creation of triggerable events on a store. Similar to the built-in
`listenables`, but for triggering.## Usage
```javascript
// myStore.js
var Reflux = require('reflux'),
triggerablesMixin = require('reflux-triggerable-mixin')(Reflux);module.exports = Reflux.createStore({
mixins: [triggerablesMixin],
listenables: {
something: Reflux.createAction()
},// The mixin turns each of these into a named action on the store.
triggerables: [
'somethingHappened'
],
// --- OR ---
triggerables: {
'somethingHappened': {}
},onSomething: function() {
this.somethingHappened.trigger('foo');
}});
``````javascript
// myComponent.js
var myStore = require('./myStore.js');myStore.somethingHappened.listen(function(what) {
console.log(what + ' happened');
});
```## Installation
```bash
$ npm install --save reflux-triggerable-mixin
```