In this lesson we'll build our actions which will be sent to our dispatcher.
What does the 'action' parameter get passed in the 'flux.dispatcher' function?
It represents a typo. :) dispatcher takes a single argument called payload. While having action and actionType (or other) fields in that payload can be useful in a larger application it is not used in this series. Expect an update to the dispatcher lesson to resolve any confusion.
In app-actions why is dispatch function called with curly braces?
addItem( item ){ dispatch({ actionType: AppConstants.ADD_ITEM, item }) }, why isn't it simply called with 2 arguments? If using named parameters and passing an object, why doesn't the second parameter have a key as well? like: {actionType: AppConstants.ADD_ITEM, item: item } ?
Following with what Joe mentioned, as of this reply there is a typo in the file app-dispatcher.js. The dispatch() function definition is meant to accept one object (named payload) as an argument (Facebook Flux API guide). This payload object (for this application so far) has 2 properties: actionType and item. In app-actions.js, the curly braces surrounding actionType and item indicate that dispatch() is being passed an object literal (for the payload). The 2nd property "item", is using es6 object property shorthand notation.
To clear this up, go to app-dispatcher.js and replace the exported dispatch function with:
export function dispatch( payload ) {
console.log(payload);
flux.dispatch( payload );
}
import Dispatcher from 'flux'; const flux = new Dispatcher(); //constructor error for flux 3.0
i had to use below instead.. import Flux from 'flux'; export default new Flux.Dispatcher;