Actions are typically the data that enters into an application, either directly from the View or from an external Web API. Each action is nothing but a JavaScript method, which contains two parts: the actionType
and the actual data. The actionCreators
methods are simply discrete, semantic helper functions that facilitate passing data to the dispatcher in the form of an action. The different types of actions are declared as a JavaScript object, in a file named App-Constants.js
. According to the Flux app hierarchy, the App-Contstants.js
file resides under src/js/constants
. Typical example for such a file looks like the following:
module.exports = { ADD_BOOK: 'ADD_BOOK', DELETE_BOOK: 'DELETE_BOOK', INC_BOOK_COUNT: 'INC_BOOK_COUNT', DEC_BOOK_COUNT: 'DEC_BOOK_COUNT' }
Here, ADD_BOOK
, DELETE_BOOK
are the actions.