Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Dispatch GET_USER multiple times #2

Open
DevAlien opened this issue Nov 24, 2015 · 2 comments
Open

Dispatch GET_USER multiple times #2

DevAlien opened this issue Nov 24, 2015 · 2 comments

Comments

@DevAlien
Copy link

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

@tommy351
Copy link
Owner

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
}

@DevAlien
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants