sparkletown/sparkle

View on GitHub
src/store/reducers/Location.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { LocationActions } from "../actions/Location";

interface LocationState {
  x: number | undefined;
  y: number | undefined;
}

const initialLocationState: LocationState = { x: undefined, y: undefined };

export const locationReducer = (
  state = initialLocationState,
  action: LocationActions
): LocationState => {
  switch (action.type) {
    case "UPDATE_LOCATION":
      return { ...state, x: action.x, y: action.y };
    default:
      return state;
  }
};