看起来是为了避免 return {...state, ...)的写法设计的 感觉还是map的样子好看一点
map = {
"increment": (state, action) => {state.value++},
"decrement": (state, action) => {state.value--},
"incrementByAmount": (state, action) => {state.value+=action.payload},
}
if v, ok := map[action.type]; ok {
return v(state, action)
}
return state