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} ) }, } }