本文整理匯總了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;