import { Accessor, createContext, createResource, Show } from "solid-js"; import { GameState, Action, vGameState, PlayerView, } from "../../../server/src/games/simple"; import api from "../api"; import Hand from "./Hand"; import Pile from "./Pile"; export const GameContext = createContext<{ view: Accessor; submitAction: (action: Action) => Promise; }>(); export default (props: { instanceId: string }) => { const [view, { mutate }] = createResource(() => api .simple(props) .get() .then((res) => res.data as PlayerView) ); const submitAction = (action: Action) => api .simple(props) .post({ action }) .then((res) => res.status == 200 && mutate(res.data as PlayerView)); return (
submitAction({ type: "draw" })} />
); };