We can summarize our application like the following to understand how it works:
- Action types SET_MEAL and SET_TIME were defined.
- Two action creators were defined:
- setMeal which generates an action with the SET_MEAL action type and a kindOfMeal property with the provided argument
- setTime which generates an action with the SET_TIME action type and a time property with the provided argument
- A reducer function was defined:
- For the action type SET_MEAL, computes a new state with a new kindOfMeal property
- For the action type SET_TIME, computes a new state with a new time property
- We defined a function that will get called when the state tree changes. Inside the function, we updated the view according to the new state.
- A dispatch function was defined that calls the reducer function providing the previous state and an action object to generate a new state.