简体   繁体   English

如果调度了一个动作,是否会调用每个Redux减速器?

[英]Will every Redux reducer be called if an action is being dispatched?

a simple question about redux. 一个关于redux的简单问题。 Is it true that if an action has been dispatched, each and every reducer is being called? 的确,如果已经调度了一个动作,那么每个缩减器都会被调用? I don't have the ability to specify one reducer function for a specific action but need to check for the action type within the reducer. 我无法为特定动作指定一个reducer函数,但需要检查reducer中的动作类型。

Is this correct? 这个对吗? How do you guys take care of your reducers? 你们如何保养减速机? Sounds to me like those functions will get pretty messy..? 在我看来,这些功能会变得非常混乱。

Yes, every reducer is called. 是的,每个减速器都被调用。

It doesn't get messy as reducers without actions will just default to the switch default case. 它不会变得混乱,因为没有动作的减速器只会默认为switch default情况。 So you don't even have to worry about it. 因此,您甚至不必担心。

You can also use combineReducers to split your reducers in multiple functions. 您还可以使用CombineReducers将减速器拆分为多个功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM