codeBelt/react-redux-architecture

[Question] How RequestingReducer is accessed

rwehresmann opened this issue · 2 comments

The RequestingReducer is a bit different from how I'm used to seeing Reducers being implemented, and I'm also not so experienced with React. If you don't mind, I would like to ask: how the RequestingReducer is accessed without a dispatch call? I understand the logic to determine if a request is finished or not, but when the store is set with ShowsAction.REQUEST_SHOW: true for instance?

I have another article that goes more in-depth: React/Redux API Loading & Errors

Basically in redux all reducers get all dispatched actions and the reducers determine which actions it cares about. For example if you dispatch ShowsAction.REQUEST_SHOW all the reducers get that action. If you look the ShowReducer you can see that is only cares about the ShowsAction.REQUEST_SHOW_FINISHED action type and not ShowsAction.REQUEST_SHOW. Now if you look at the RequestingReducer you can see we care about all action types that start with REQUEST_ and since all reducers get all actions we handle ShowsAction.REQUEST_SHOW and ShowsAction.REQUEST_SHOW_FINISHED.

I hope this answers your question

Question answered, thanks a lot!