[Redux] Reducer Composition with combineReducers()

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
});

 

posted @ 2015-12-22 02:24  Zhentiw  阅读(288)  评论(0编辑  收藏  举报