Creating actions
Actions initiate changes to our store state. In this section, we are going to create functions that create all the actions in our store. We will start by understanding all the actions that will be required in our store.
Understanding the actions in the store
The three processes that will interact with the store are as follows:
- Fetching and rendering the unanswered questions on the home page
- Fetching and rendering the question being viewed on the question page
- Searching questions and showing the matches on the search page
Each process comprises the following steps:
- When the process starts, the store's
loading
state is set totrue
. - The request to the server is then made.
- When the response from the server is received, the data is put into the appropriate place in the store's state and
loading
is set tofalse
.
Each process has two state changes. This means that each process requires two actions:
- An action...