Dispatch GET_USER multiple times
Hi, I've been playing around with your redux example and it is pretty cool, it does its job.
While checking the files, i run into the actions of the user and found that you dispatch the GET_USER 2 times, and the first time you don't do any actions. https://github.com/tommy351/redux-example/blob/master/src/actions/users.js Is there a reason for that?
Thanks for your time
The first dispatch means the request started, it can be used on loading indicator for example. The second dispatch will be either success or failed. Here's the content of actions:
// Dispatch #1: Started
{
type: 'GET_USER'
}
// Dispatch #2: Success
{
type: 'GET_USER',
payload: {
// ...
}
}
// Dispatch #2: Failed
{
type: 'GET_USER',
payload: {
// ...
},
error: true
}
Ah ok, so why not calling them with different names? For me it does not make a lot of sense to use the same action for 2 different things