Created
January 5, 2021 17:08
-
-
Save brian-lim-42/b4e035a974bbdd91926f80151c6bcd40 to your computer and use it in GitHub Desktop.
Dynamic Global Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { makeVar } from '@apollo/client'; | |
// could strongly type here | |
// leaving it dynamic for general use | |
type Store = { [key: string]: any } | |
const store: Store = {} | |
export const add = (key: string) => { | |
store[key] = makeVar(key); | |
} | |
export const set = (key: string, value: any) => store[key](value); | |
export const get = (key: string) => store[key](); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment