Skip to content

Reflux stores mixin adding `triggerable` syntax similar to `listenable`.

Notifications You must be signed in to change notification settings

jesstelford/reflux-triggerable-mixin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reflux Triggerable Mixin

Mixin for reflux stores to enable quick creation of triggerable events on a store. Similar to the built-in listenables, but for triggering.

Usage

// 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': {<refulx action options>}
  },

  onSomething: function() {
    this.somethingHappened.trigger('foo');
  }

});
// myComponent.js
var myStore = require('./myStore.js');

myStore.somethingHappened.listen(function(what) {
  console.log(what + ' happened');
});

Installation

$ npm install --save reflux-triggerable-mixin

About

Reflux stores mixin adding `triggerable` syntax similar to `listenable`.

Resources

Stars

Watchers

Forks

Packages

No packages published