diff options
| author | Mel <einebeere@gmail.com> | 2022-02-17 22:30:43 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-02-17 22:30:43 +0100 |
| commit | 948e960c6cb5a0f33af66b8b4a26dd56bcf13988 (patch) | |
| tree | 4eeb3be4c0ea12ef5eff04c766809d54af0280d5 /assets/src/state/constant_state.ts | |
| parent | 50d3d4080a5b8bf0819e168aa2301e3124a55300 (diff) | |
| download | rook-948e960c6cb5a0f33af66b8b4a26dd56bcf13988.tar.zst rook-948e960c6cb5a0f33af66b8b4a26dd56bcf13988.zip | |
Rename stores/ to state/ since it no longer includes just state in stores.
Diffstat (limited to 'assets/src/state/constant_state.ts')
| -rw-r--r-- | assets/src/state/constant_state.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/assets/src/state/constant_state.ts b/assets/src/state/constant_state.ts new file mode 100644 index 0000000..aeda86e --- /dev/null +++ b/assets/src/state/constant_state.ts @@ -0,0 +1,33 @@ +// Cannot be changed after being set. + +import { RookType } from "../models/rook_type"; + +let clientType: RookType = null; + +export function setClientType(type: RookType) { + if (clientType !== null) { + clientType = type; + } else { + throw new Error("Tried changing client type after initialization."); + } +} + +export function isClientShare() { + if (clientType === null) { + throw new Error( + "Tried accessing client type before initialization was completed." + ); + } + + return clientType === RookType.SHARE; +} + +export function isClientRequest() { + if (clientType === null) { + throw new Error( + "Tried accessing client type before initialization was completed." + ); + } + + return clientType === RookType.REQUEST; +} |
