use error update to show error modal

This commit is contained in:
evanpelle
2025-01-23 19:40:52 -08:00
committed by Evan
parent 4bbb63fd48
commit d009ef925c
4 changed files with 35 additions and 13 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
import { PlayerActions, PlayerID, PlayerInfo, PlayerProfile } from "../game/Game";
import { GameUpdateViewData } from '../game/GameUpdates';
import { ErrorUpdate, GameUpdateViewData } from '../game/GameUpdates';
import { GameConfig, GameID, Turn } from "../Schemas";
import { generateID } from "../Util";
import { WorkerMessage } from "./WorkerMessages";
@@ -8,7 +8,7 @@ export class WorkerClient {
private worker: Worker;
private isInitialized = false;
private messageHandlers: Map<string, (message: WorkerMessage) => void>;
private gameUpdateCallback?: (update: GameUpdateViewData) => void;
private gameUpdateCallback?: (update: GameUpdateViewData | ErrorUpdate) => void;
constructor(private gameID: GameID, private gameConfig: GameConfig) {
this.worker = new Worker(new URL('./Worker.worker.ts', import.meta.url));
@@ -67,7 +67,7 @@ export class WorkerClient {
});
}
start(gameUpdate: (gu: GameUpdateViewData) => void) {
start(gameUpdate: (gu: GameUpdateViewData | ErrorUpdate) => void) {
if (!this.isInitialized) {
throw new Error('Failed to initialize pathfinder');
}