I found this very convenient to use mixins to declare actions generators:
var TodoActions = { createTodo: function (text) { AppDispatcher.handleViewAction({ actionType: TodoConstants.TODO_CREATE, text: text }); }, destroy: function (id) { AppDispatcher.handleViewAction({ actionType: TodoConstants.TODO_DESTROY, id: id }); } };
And then it can be used like this:
var TodoItem = React.createClass({ mixins: [TodoActions], //... example _onDestroyClick: function() { // instead of calling // TodoActions.destroy(this.props.todo.id); // we can call now this.destroyTodo(this.props.todo.id); } });
Links:
Flux — application architecture for building user interfaces
React.js — javascript library for building user interfaces













