Platform: Question: Do both Reducers and Effects handle Actions?

Created on 17 Feb 2018  路  4Comments  路  Source: ngrx/platform

Hi
I'm learning ngrx store and I'm new.

I know that Reducers are like Action Listeners. Then I learned that Effects can also handle Actions. I'm a bit lost here. Isnt the case that Reducers are the only ones who can handle Actions and change State?

Thanks

Most helpful comment

Yes. More specifically all actions hit all reducers first, then the action is passed to the effects.

All 4 comments

Reducers use actions to change state. Effects are used to listen for actions and return new actions

Hi @brandonroberts what if both Reducers and Effects listen to the same Action. Who runs first? So as an example an Effect might listen to an Action to load data from server. This action doesn't change State so no need to listen 5o it by a reducer. Effects listen to the action and loads data from server and then fires an event with a payload of data received and raises an event for the reducer to catch and update state accordingly? That's how it works?

Thanks

Yes. More specifically all actions hit all reducers first, then the action is passed to the effects.

Thanks a lot @brandonroberts !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mappedinn picture mappedinn  路  3Comments

shyamal890 picture shyamal890  路  3Comments

sandangel picture sandangel  路  3Comments

NathanWalker picture NathanWalker  路  3Comments

ghost picture ghost  路  3Comments