Im experimenting with redux-like contstructs, which reduce the boilerplatey stuff, for example:
export function setStatePlain(state: State) {
return {
type: SET_STATE,
payload: state,
} as const;
}
export function setState(state: DeepPartial): Thunk {
return (dispatch, getState) => {
dispatch(setStatePlain(Object.assign({}, getState(), state)));
};
}
export function someAction(data: Data): Thunk {
...
dispatch(setState(immer.produce(getState(), state => {
state.lobbyGames[result.data.uuid] = {
...result.data,
adminId: state.playerId,
players: [{
id: state.playerId,
name: state.playerName,
ready: false,
}],
};
...
}
})));