aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/lib/stores
diff options
context:
space:
mode:
Diffstat (limited to 'web/pw-server/src/lib/stores')
-rw-r--r--web/pw-server/src/lib/stores/editor_state.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/web/pw-server/src/lib/stores/editor_state.ts b/web/pw-server/src/lib/stores/editor_state.ts
new file mode 100644
index 0000000..c0462e1
--- /dev/null
+++ b/web/pw-server/src/lib/stores/editor_state.ts
@@ -0,0 +1,27 @@
+import { writable } from "svelte/store";
+
+const MAX_MATCHES = 100;
+
+function createMatchHistory() {
+ const { subscribe, update } = writable([]);
+
+ function pushMatch(match: object) {
+ update((matches) => {
+ if (matches.length == MAX_MATCHES) {
+ matches.pop();
+ }
+ matches.unshift(match);
+
+ return matches;
+ });
+ }
+
+ return {
+ subscribe,
+ pushMatch,
+ };
+}
+
+export const matchHistory = createMatchHistory();
+export const selectedOpponent = writable(null);
+export const selectedMap = writable(null);