mancala/apps/mobile/src/context/context.tsx

31 lines
945 B
TypeScript
Raw Normal View History

import { server } from "../const/config";
2024-06-17 18:52:26 +03:00
import { RTMT, RTMTWS, ThemeManager, Storage } from "@mancala/core";
import { HttpServiceImpl } from "../service/HttpService";
import { GameStore, GameStoreImpl } from "../store/GameStore";
import { UserKeyStore, UserKeyStoreImpl } from "../store/KeyStore";
2024-06-17 18:52:26 +03:00
import { LocalStorage } from "../storage";
export type Context = {
rtmt: RTMT;
userKeyStore: UserKeyStore;
themeManager: ThemeManager;
gameStore: GameStore;
2024-06-17 18:52:26 +03:00
storage: Storage;
};
export const initContext = (): Context => {
const rtmt = new RTMTWS();
const httpService = new HttpServiceImpl(server.serverAdress);
const userKeyStore = new UserKeyStoreImpl({ httpService });
const gameStore = new GameStoreImpl({ httpService });
2024-06-17 18:52:26 +03:00
const storage = new LocalStorage();
const themeManager = new ThemeManager(storage);
return {
rtmt: rtmt,
userKeyStore: userKeyStore,
themeManager,
2024-06-17 18:52:26 +03:00
gameStore,
storage
};
};