Redux:为主减速器的子元素构建减速器

Redux:为主减速器的子元素构建减速器,redux,Redux,可能是个愚蠢的问题。我有一个基于Immutable.js记录构建的Redux reducer: export const Editors = new Record({ 'editors': new List(), // this is a list of Editor items below }) export const Editor = new Record({ 'id': null, 'state': EditorState.createEmpty(),

可能是个愚蠢的问题。我有一个基于Immutable.js记录构建的Redux reducer:

export const Editors = new Record({
    'editors': new List(), // this is a list of Editor items below
})

export const Editor = new Record({    
    'id': null,
    'state': EditorState.createEmpty(),
    'annotations': new List(),
});
我以这种方式构建东西,因为我希望我正在构建的应用程序有许多编辑器

但是,我想编写一个更新单个编辑器状态的
updateState
操作。我想,如果我能够编写作用于特定
编辑器
的reducer代码,而不是在我的
编辑器
reducer中的
编辑器
列表上的reducer代码,那么写这篇文章就会容易得多。有没有一种方法可以编写reducer代码,这样我就可以在单个编辑器中更新字段的状态,而不是在列表中查找编辑器、删除它、更新它、重新插入它等等

export const Editors = new Record({
    'editors': new Map(), // this is a list of Editor items below
})

export const Editor = new Record({    
    'id': null,
    'state': EditorState.createEmpty(),
    'annotations': new List(),
});
然后更新编辑器变成:

const updateEditorState = (Editors, id, editorState) =>
   Editors.setIn(['editors', id, 'state']¸editorState)
顺便说一句,你的名字有点奇怪。我会选择小写的
编辑器
编辑器