diff options
Diffstat (limited to 'cloud/web/src/util')
| -rw-r--r-- | cloud/web/src/util/context.tsx | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/cloud/web/src/util/context.tsx b/cloud/web/src/util/context.tsx deleted file mode 100644 index d1c6f4e7f..000000000 --- a/cloud/web/src/util/context.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { ParentProps, Show, createContext, useContext } from "solid-js" - -export function createInitializedContext< - Name extends string, - T extends { ready: boolean }, ->(name: Name, cb: () => T) { - const ctx = createContext<T>() - - return { - use: () => { - const context = useContext(ctx) - if (!context) throw new Error(`No ${name} context`) - return context - }, - provider: (props: ParentProps) => { - const value = cb() - return ( - <Show when={value.ready}> - <ctx.Provider value={value} {...props}> - {props.children} - </ctx.Provider> - </Show> - ) - }, - } -} |
