码迷,mamicode.com
首页 > 其他好文 > 详细

[Redux] Reducer Composition with combineReducers()

时间:2015-12-22 06:28:30      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

Previous, we do composition with objects:

const todoApp = (state = {}, action) => {
  return {
    todos: todos(
      state.todos,
      action
    ),
    visibilityFilter: visibilityFilter(
      state.visibilityFilter,
      action
    )
  };
};

 

Since it is common options in Redux,  there is a function call ‘combineReducers‘:

const {combineReducers} = Redux;
combineReducers({
   todos,   //ES6 shortcut syntax
   visibilityFilter
});

 

[Redux] Reducer Composition with combineReducers()

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5065436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!