Skip to content

Instantly share code, notes, and snippets.

@tribou
Last active August 29, 2015 14:23
Show Gist options
  • Save tribou/b1df6694a50ddaecd96e to your computer and use it in GitHub Desktop.
Save tribou/b1df6694a50ddaecd96e to your computer and use it in GitHub Desktop.
Todo app actions for React and Flux architecture
// Todo actions
var AppDispatcher = require('../dispatcher/AppDispatcher');
var TodoConstants = require('../constants/TodoConstants');
module.exports = {
addItem: function() {
AppDispatcher.handleViewAction({
actionType: TodoConstants.NEW_ITEM
});
},
saveItem: function(text) {
AppDispatcher.handleViewAction({
actionType: TodoConstants.SAVE_ITEM,
text: text
});
},
removeItem: function(index) {
AppDispatcher.handleViewAction({
actionType: TodoConstants.REMOVE_ITEM,
index: index
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment