From 183e0911b76025a1f2a82e979d9834fec2131d0e Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 8 Aug 2025 13:22:54 -0400 Subject: wip: gateway --- cloud/web/src/util/context.tsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cloud/web/src/util/context.tsx (limited to 'cloud/web/src/util') diff --git a/cloud/web/src/util/context.tsx b/cloud/web/src/util/context.tsx new file mode 100644 index 000000000..d1c6f4e7f --- /dev/null +++ b/cloud/web/src/util/context.tsx @@ -0,0 +1,26 @@ +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() + + return { + use: () => { + const context = useContext(ctx) + if (!context) throw new Error(`No ${name} context`) + return context + }, + provider: (props: ParentProps) => { + const value = cb() + return ( + + + {props.children} + + + ) + }, + } +} -- cgit v1.2.3