0.1.0 #1
@@ -19,7 +19,7 @@ export class Reffuse<
|
||||
) {
|
||||
this.Provider = parent
|
||||
? ReffuseReactContext.makeNestedProvider(runtime, this.Context, parent)
|
||||
: ReffuseReactContext.makeRootProvider<RuntimeR, OwnContextR>(runtime, this.Context)
|
||||
: ReffuseReactContext.makeRootProvider(runtime, this.Context)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,15 +24,21 @@ export interface ProviderProps<
|
||||
readonly children?: React.ReactNode
|
||||
}
|
||||
|
||||
export function makeRootProvider<RuntimeR, ContextR>(
|
||||
export function makeRootProvider<
|
||||
RuntimeR,
|
||||
ContextR extends ParentContextR | OwnContextR,
|
||||
OwnContextR,
|
||||
ParentContextR,
|
||||
>(
|
||||
runtime: Runtime.Runtime<RuntimeR>,
|
||||
ReactContext: React.Context<Value<RuntimeR, ContextR>>,
|
||||
): Provider<RuntimeR, ContextR, never> {
|
||||
): Provider<RuntimeR, OwnContextR, ParentContextR> {
|
||||
return function ReffuseRootReactContextProvider(props) {
|
||||
const value = React.useMemo(() => ({
|
||||
runtime,
|
||||
context: Effect.context<ContextR>().pipe(
|
||||
Effect.provide(props.layer),
|
||||
Effect.provide(Context.empty() as Context.Context<ParentContextR>), // Just there for type safety. ParentContextR is always never here anyway
|
||||
Runtime.runSync(runtime),
|
||||
),
|
||||
}), [props.layer])
|
||||
|
||||
Reference in New Issue
Block a user