Actions
Actions represent unique events in our application. Reducer functions will process the actions in order to update state.
An action is a simple object with a type
property:
Now we can dispatch the addTodo
action to the store and let the reducers calculate the new global state.
#
Action CreatorsOf course, we do not want to create these action objects "by hand" when we need to dispatch an action. Action Creators will do the repetitive work for us.
#
"Classic" Action CreatorsDispatch the action:
#
Class-based Action Creators (TypeScript)todo.ts
todo-actions.ts
Dispatch the actions:
The upcoming code examples use Class-based Action Creators.
#
Ts-actionWith ts-action you can create actions and reducers with a minimum of boilerplate code. Read more in the ts-action section.