Our first Actions will be simple, they’ll take in an array of locations and just dispatch them to the Store.
We create actions by invoking alt.createActions()
with the methods that will become the actions. Whatever
value you return from these methods will be transparently sent through the dispatcher and onto the Stores.
actions/LocationActions.js
import alt from '../alt';
const LocationActions = {
updateLocations(locations) {
return locations;
}
}
export default alt.createActions('LocationActions', LocationActions);
Quite frequently actions will be like this example, just forwarding the value to the dispatcher.
We include a more convenient method for this case using a generate
attribute.
This is equivalent to our last example:
import alt from '../alt';
export default alt.createActions('LocationActions', { generate: [ 'updateLocations' ] });