feat(app): cache session-scoped stores, optional context gating

This commit is contained in:
Adam
2026-01-08 07:41:20 -06:00
parent c949e5b390
commit be9b2bab15
6 changed files with 469 additions and 231 deletions

View File

@@ -3,12 +3,19 @@ import { createContext, createMemo, Show, useContext, type ParentProps, type Acc
export function createSimpleContext<T, Props extends Record<string, any>>(input: {
name: string
init: ((input: Props) => T) | (() => T)
gate?: boolean
}) {
const ctx = createContext<T>()
return {
provider: (props: ParentProps<Props>) => {
const init = input.init(props)
const gate = input.gate ?? true
if (!gate) {
return <ctx.Provider value={init}>{props.children}</ctx.Provider>
}
// Access init.ready inside the memo to make it reactive for getter properties
const isReady = createMemo(() => {
// @ts-expect-error