Skip to content

Commit

Permalink
add ClientRoom interface
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshidwivedi committed Jun 22, 2024
1 parent 252a4e3 commit 5257bbf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/recoil/room/room.atom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { atom } from "recoil";

export const roomAtom = atom({
export const roomAtom = atom<ClientRoom>({
key: "room",
default: {
id: "",
Expand Down
4 changes: 2 additions & 2 deletions common/recoil/room/room.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useSetRoomId = () => {
const setRoomId= useSetRecoilState(roomAtom);

const handleSetRoomId = (id: string) => {
setRoomId({id});
setRoomId((prev)=> ({...prev,id}));
};
return handleSetRoomId
return handleSetRoomId;
};
7 changes: 7 additions & 0 deletions common/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export declare global {

type Room = {users: Map<string, Move[]>; drawed: Move[]};

interface ClientRoom{
id:string;
users: Map<string, Move[]>;
movesWithoutUser: Move[];
myMoves: Move[];
}

interface ServerToClientEvents {
room: (room: Room, usersToParse: string)=> void;
created: (roomId: string) => void;
Expand Down

0 comments on commit 5257bbf

Please sign in to comment.