Skip to content

gingur/fluxible-plugin-actions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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(){
    ...
  }
});

About

Provide actions via context to your fluxible application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published