aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/lib/stores/editor_state.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/pw-server/src/lib/stores/editor_state.ts')
-rw-r--r--web/pw-server/src/lib/stores/editor_state.ts26
1 files changed, 26 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..641994b
--- /dev/null
+++ b/web/pw-server/src/lib/stores/editor_state.ts
@@ -0,0 +1,26 @@
+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);