Switch to implicit state

This commit is contained in:
Jon Staab
2024-10-24 14:02:43 -07:00
parent cce5761235
commit ceb7f3340d
4 changed files with 41 additions and 12 deletions
+14
View File
@@ -0,0 +1,14 @@
// Use this for passing state between pages implicitly
const state = new Map<string, any>()
export const setKey = <T>(key: string, value: T) => state.set(key, value)
export const getKey = <T>(key: string) => state.get(key) as T | undefined
export const popKey = <T>(key: string) => {
const value: T | undefined = state.get(key)
state.delete(key)
return value
}