15 lines
397 B
TypeScript
15 lines
397 B
TypeScript
import { Socket } from "socket.io-client";
|
|
import { ServerEvent } from "./ServerEvent";
|
|
|
|
export type UpdateLobbyEvent = {
|
|
playerNames: Array<string>;
|
|
};
|
|
|
|
export function attachHandlerToUpdateLobbyEvent(
|
|
socket: Socket,
|
|
handler: (event: UpdateLobbyEvent) => void,
|
|
): () => void {
|
|
socket.on(ServerEvent.LOBBY_UPDATE, handler);
|
|
return () => socket.off(ServerEvent.LOBBY_UPDATE, handler);
|
|
}
|