Confused betewen reducers and dispatchers concerning actions

Viewed 34

I'm a bit confused about reducers and dispatchers. Both will get actions as a parameter, but it doesn't mean that my dispatchers' actions are the same of my reducers actions, right?

Let say I have an action called fetchData, that action will be dispatch but won't reach the reducer since it doesn't modify the state.

All tutorials I read about redux, teach to set all the actions in one place. I think we should have reducersActions and dispatchersActions.

Am I missing something?

1 Answers

IMHO, Breaking actions as reducersActions and dispatchersActioncan be done but it is not a standard convention.

When you define an action, basically it revolves around an entity (for which you define a state and maintain it later) . The naming conventions of actions should clarify the intention of it's existence, and it varies as discussed here.

So keeping action at one place but with proper naming (which reflects the intention) of action should be good enough to understand whether its a call to reducer (which will only return new state) or dispatcher (which will fan out more actions).

In your example of fetchData , there is no clarity of its purpose. Focus on states, and then start creating actions. Things will automatically fall into place.

Related