Fluxible
Pluggable, singleton-free container for isomorphic Flux applications.
$ npm install --save fluxible
Docs
Features
Usage
var Fluxible = require('fluxible');
var React = require('react');
var action = function (context, payload, done) {
context.dispatch('FOO_ACTION', payload);
done();
};
var createStore = require('fluxible/addons').createStore;
var Store = createStore({
storeName: 'FooStore',
handlers: {
'FOO_ACTION': 'fooHandler'
},
initialize: function () {
this.foo = null;
},
fooHandler: function (payload) {
this.foo = payload;
},
getState: function () {
return {
foo: this.foo
}
}
});
var App = React.createClass({
mixins: [Fluxible.FluxibleMixin],
statics: {
storeListeners: [Store]
},
getInitialState: function () {
return this.getStore(Store).getState();
},
onChange: function () {
this.setState(this.getStore(Store).getState());
},
render: function () {
return <span>{this.state.foo}</span>
}
});
var fluxibleApp = new Fluxible({
component: App
});
fluxibleApp.registerStore(Store);
var context = fluxibleApp.createContext();
context.executeAction(action, 'bar', function () {
console.log(React.renderToString(context.createElement()));
});
License
This software is free to use under the Yahoo Inc. BSD license.
See the LICENSE file for license text and copyright information.