mancala/src/context/context.tsx

33 lines
993 B
TypeScript
Raw Normal View History

2022-07-30 16:32:13 +03:00
import { server } from "../const/config";
2022-07-14 13:38:00 +03:00
import { Texts, TrTr } from "../const/texts";
import { RTMT } from "../rtmt/rtmt";
import { RTMTWS } from "../rtmt/rtmt_websocket";
2022-07-30 16:32:13 +03:00
import { HttpServiceImpl } from "../service/HttpService";
import { GameStore, GameStoreImpl } from "../store/GameStore";
import { UserKeyStore, UserKeyStoreImpl } from "../store/KeyStore";
2022-07-14 13:38:00 +03:00
import ThemeManager from "../theme/ThemeManager";
2021-06-27 19:28:55 +03:00
2022-05-15 01:58:57 +03:00
export type Context = {
rtmt: RTMT;
userKeyStore: UserKeyStore;
texts: Texts;
themeManager: ThemeManager;
2022-07-30 16:32:13 +03:00
gameStore: GameStore;
2022-05-15 01:58:57 +03:00
};
2021-06-27 19:28:55 +03:00
2022-07-30 16:32:13 +03:00
export const initContext = (): Context => {
2022-05-15 01:58:57 +03:00
const rtmt = new RTMTWS();
2022-07-30 16:32:13 +03:00
const httpService = new HttpServiceImpl(server.serverAdress);
const userKeyStore = new UserKeyStoreImpl({ httpService });
const gameStore = new GameStoreImpl({ httpService });
2022-05-15 01:58:57 +03:00
const texts = TrTr;
2022-06-04 19:28:57 +03:00
const themeManager = new ThemeManager();
2022-05-15 01:58:57 +03:00
return {
rtmt: rtmt,
userKeyStore: userKeyStore,
texts: texts,
themeManager,
2022-07-30 16:32:13 +03:00
gameStore
2022-05-15 01:58:57 +03:00
};
};