本文整理汇总了TypeScript中redux-typed-modules.Module.createReducer方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Module.createReducer方法的具体用法?TypeScript Module.createReducer怎么用?TypeScript Module.createReducer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redux-typed-modules.Module
的用法示例。
在下文中一共展示了Module.createReducer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: initialState
widgets: s.widgets.update(a.name, (v) => {
if (typeof v === 'undefined') return v;
v.position.visibility = !v.position.visibility;
return v;
}),
};
},
});
export const resetHUDWidget = module.createAction({
type: 'layout/RESET_HUD_WIDGET',
action: (name: string) => {
return {
name,
};
},
reducer: (s, a) => {
const defaultWidgets = initialState().widgets;
return {
widgets: s.widgets.update(a.name, (v) => {
if (typeof v === 'undefined') return v;
v.position = defaultWidgets.get(a.name).position;
saveState(s, v, a.name);
return v;
}),
};
},
});
export default module.createReducer();
示例2: updateCharacterCounts
characters[a.character.id] = a.character;
const servers = updateCharacterCounts(utils.clone(s.servers), characters);
return {
characters,
servers,
};
},
});
export const characterRemoved = module.createAction({
type: 'controller/characterRemoved',
action: (id: string) => {
return {
id,
};
},
reducer: (s, a) => {
const characters = utils.clone(s.characters);
delete characters[a.id];
const servers = updateCharacterCounts(utils.clone(s.servers), characters);
return {
characters,
servers,
};
},
});
export const reducer = module.createReducer();
export default reducer;