0.1.0 #1

Merged
Thilawyn merged 81 commits from next into master 2025-07-17 21:17:57 +02:00
Showing only changes of commit 09267cd50b - Show all commits

View File

@@ -85,6 +85,33 @@ export const useFC: {
))
})
export const useSuspenseFC: {
<E, R, P extends {}>(
self: Component<E, R, P>
): Effect.Effect<React.FC<P>, never, Exclude<R, Scope.Scope>>
} = Effect.fn("useSuspenseFC")(function* <E, R, P extends {}>(
self: Component<E, R, P>
) {
const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!)
runtimeRef.current = yield* Effect.runtime<Exclude<R, Scope.Scope>>()
return React.useMemo(() => function ScopeProvider(props: P) {
const scope = Runtime.runSync(runtimeRef.current)(Hook.useScope([], self.options))
const FC = React.useMemo(() => {
const f = (props: P) => Runtime.runSync(runtimeRef.current)(
Effect.provideService(self(props), Scope.Scope, scope)
)
f.displayName = self.displayName ?? "Anonymous"
return f
}, [scope])
return React.createElement(FC, props)
}, Array.from(
Context.omit(...nonReactiveTags)(runtimeRef.current.context).unsafeMap.values()
))
})
export const use: {
<E, R, P extends {}>(
self: Component<E, R, P>,