Provide actions via context to your fluxible application
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
index.js
package.json

README.md

fluxible-plugin-actions

Provide action creators via context to your fluxible application

##Install Add the package

npm install --save fluxible-plugin-actions

Add to your app

var actionPlugin = require('fluxible-plugin-actions');
var app = require('...');

app.plug(actionPlugin());
/* or */
app.plug(actionPlugin({
    actions: {
        'ACTION_NAME': function (context, payload, done) {
            ...
            context.dispatch('STORE_ACTION', payload);
            ...
            done(); // Not available for component actions
        }
    }
});

Add to your app context

var app = require('...');
var actions = require('...');
var context = app.createContext({
    req: req,
    actions: actions
});

Enable in your component context

var React = require('react');
var provideContext = require('fluxible/addons');
var Application = React.createClass({...});

Application = provideContext(Application, { 'getAction': React.PropTypes.func });

##Context Add to your component contextTypes

var React = require('react');
module.exports = React.createClass({
  contextTypes: {
    getAction: React.PropTypes.func.isRequired,
    executeAction: React.PropTypes.func.isRequired
  },
  _someEvent: function(e){
    var action = this.context.getAction('ACTION_KEY');
    var payload = { ... };
    this.context.executeAction(action, payload);
  },
  render: function(){
    ...
  }
});