Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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`.

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
```