v0.8.2
Interface: CustomEventMap
Interface for custom event maps that consumers of the library can extend
Example usage:
// Define your game event constants
const GAME_EVENTS = {
STARTED: "game:started",
ENDED: "game:ended",
PAUSED: "game:paused",
RESUMED: "game:resumed",
ROUND_STARTED: "game:round:started",
ROUND_ENDED: "game:round:ended",
TURN_STARTED: "game:turn:started",
TURN_ENDED: "game:turn:ended"
} as const;
// Define your game-specific event constants
const POKER_EVENTS = {
HAND_DEALT: "poker:hand:dealt",
BETTING_ROUND_STARTED: "poker:betting:started",
PLAYER_CALLED: "poker:player:called",
PLAYER_RAISED: "poker:player:raised",
PLAYER_FOLDED: "poker:player:folded"
} as const;
// Create types for your custom events
type GameEventType = typeof GAME_EVENTS[keyof typeof GAME_EVENTS];
type PokerEventType = typeof POKER_EVENTS[keyof typeof POKER_EVENTS];
// Extend the event system
declare module "shoehive" {
interface CustomEventMap {
gameEvents: GameEventType;
pokerEvents: PokerEventType;
}
}