Redux如何使用CombineReducer避免操作重复

时间:2019-06-06 07:39:44

标签: redux

使用combineReducer似乎将动作传递给所有的reducer,因此在大型应用程序中,相同的reducer可能最终会响应相同的动作:

message = (state=[], action) ->
  switch action.type
    when NEW_MESSAGE
      state # new state
unread = (state=[], action) ->
  switch action.type
    when NEW_MESSAGE
      state # new state
thread = (state=[], action) ->
  switch action.type
    when NEW_MESSAGE
      state # new state

combineReducer {message, unread, thread}

是否有避免这种情况的解决方案?如果它是一个大型应用程序,并且我仅在一个子减速器中工作,这是否意味着我需要手动检查所有减速器操作,以避免发生冲突?

0 个答案:

没有答案
相关问题