traintrape-moi/client/hooks/useGame.ts

13 lines
477 B
TypeScript
Raw Normal View History

2024-12-11 16:26:36 +00:00
import { useAppDispatch, useAppSelector } from "./useStore"
import { setPlayerId, updateMoney } from "@/utils/features/game/gameSlice"
export const useGame = () => useAppSelector((state) => state.game)
export const useSetPlayerId = () => {
const dispath = useAppDispatch()
return (playerId: number) => dispath(setPlayerId(playerId))
}
export const useUpdateMoney = () => {
const dispatch = useAppDispatch()
return (money: number) => dispatch(updateMoney(money))
}