fixxxxxxxx
This commit is contained in:
35
components/providers/game-launch-store.ts
Normal file
35
components/providers/game-launch-store.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
type GameLaunchState = {
|
||||
isOpen: boolean;
|
||||
placeId?: string;
|
||||
gameInstanceId?: string;
|
||||
};
|
||||
|
||||
let state: GameLaunchState = { isOpen: false };
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
function emit() {
|
||||
listeners.forEach((listener) => listener());
|
||||
}
|
||||
|
||||
export function getGameLaunchState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
export function subscribeGameLaunch(listener: () => void) {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
}
|
||||
|
||||
export function openGameLaunchWithParams(placeId: string, jobId?: string) {
|
||||
state = {
|
||||
isOpen: true,
|
||||
placeId,
|
||||
gameInstanceId: jobId
|
||||
};
|
||||
emit();
|
||||
}
|
||||
|
||||
export function closeGameLaunch() {
|
||||
state = { isOpen: false };
|
||||
emit();
|
||||
}
|
||||
Reference in New Issue
Block a user