You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
hexmap/client/src/reducers/NetworkReducer.ts

24 lines
915 B

import {AppState} from "../state/AppState";
import {isClientAction} from "../../../common/src/actions/ClientAction";
import {clientReducer} from "./ClientReducer";
import {serverReducer} from "./ServerReducer";
import {NetworkAction} from "../../../common/src/actions/NetworkAction";
import {isServerAction} from "../../../common/src/actions/ServerAction";
import {exhaustivenessCheck} from "../../../common/src/util/TypeUtils";
export function networkReducer(oldState: AppState, action: NetworkAction): AppState {
if (isClientAction(action)) {
const newState = clientReducer(oldState.network, action)
if (newState === oldState.network)
{
return oldState
}
return {
...oldState,
network: newState
}
} else if (isServerAction(action)) {
return serverReducer(oldState, action)
}
exhaustivenessCheck(action)
}