0.1.11 #14

Merged
Thilawyn merged 318 commits from next into master 2025-05-19 14:01:41 +02:00
Showing only changes of commit a28d6c3d30 - Show all commits

View File

@@ -76,10 +76,8 @@ const makeProvider = <R>(Context: React.Context<Context.Context<R>>): ReactProvi
export type AsyncReactProvider<R> = React.FC<{ export type AsyncReactProvider<R> = React.FC<{
readonly layer: Layer.Layer<R, unknown, Scope.Scope> readonly layer: Layer.Layer<R, unknown, Scope.Scope>
readonly options?: {
readonly scope?: Scope.Scope readonly scope?: Scope.Scope
readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy
}
readonly fallback?: React.ReactNode readonly fallback?: React.ReactNode
readonly children?: React.ReactNode readonly children?: React.ReactNode
}> }>
@@ -106,9 +104,9 @@ const makeAsyncProvider = <R>(Context: React.Context<Context.Context<R>>): Async
const { promise, resolve, reject } = Promise.withResolvers<Context.Context<R>>() const { promise, resolve, reject } = Promise.withResolvers<Context.Context<R>>()
setPromise(promise) setPromise(promise)
const scope = runSync(props.options?.scope const scope = runSync(props.scope
? Scope.fork(props.options.scope, props.options?.finalizerExecutionStrategy ?? ExecutionStrategy.sequential) ? Scope.fork(props.scope, props.finalizerExecutionStrategy ?? ExecutionStrategy.sequential)
: Scope.make(props.options?.finalizerExecutionStrategy) : Scope.make(props.finalizerExecutionStrategy)
) )
Effect.context<R>().pipe( Effect.context<R>().pipe(
@@ -119,7 +117,7 @@ const makeAsyncProvider = <R>(Context: React.Context<Context.Context<R>>): Async
Effect.provide(props.layer), Effect.provide(props.layer),
Effect.provideService(Scope.Scope, scope), Effect.provideService(Scope.Scope, scope),
effect => runFork(effect, { ...props.options, scope }), effect => runFork(effect, { ...props, scope }),
) )
return () => { runFork(Scope.close(scope, Exit.void)) } return () => { runFork(Scope.close(scope, Exit.void)) }