Refactoring
All checks were successful
Lint / lint (push) Successful in 11s

This commit is contained in:
Julien Valverdé
2025-07-16 12:53:37 +02:00
parent 591ec17e9f
commit da3b672441

View File

@@ -26,14 +26,7 @@ const nonReactiveTags = [Tracer.ParentSpan] as const
export namespace make { export namespace make {
export interface Options { export type Gen = {
readonly untraced?: boolean
readonly finalizerExecutionMode?: "sync" | "fork"
readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy
}
}
export const make: {
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, P extends {} = {}>( <Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, P extends {} = {}>(
body: (props: P) => Generator<Eff, React.ReactNode, never>, body: (props: P) => Generator<Eff, React.ReactNode, never>,
): Component< ): Component<
@@ -176,7 +169,16 @@ export const make: {
h: (_: G, props: NoInfer<P>) => H, h: (_: G, props: NoInfer<P>) => H,
i: (_: H, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>, i: (_: H, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P> ): Component<EOut, ROut, P>
} = (...pipeables: readonly [any]) => { }
export interface Options {
readonly untraced?: boolean
readonly finalizerExecutionMode?: "sync" | "fork"
readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy
}
}
export const make: make.Gen = (...pipeables: readonly [any]) => {
const displayName: string = !String.isEmpty(pipeables[0].name) ? pipeables[0].name : undefined const displayName: string = !String.isEmpty(pipeables[0].name) ? pipeables[0].name : undefined
return Object.setPrototypeOf({ return Object.setPrototypeOf({
@@ -187,30 +189,10 @@ export const make: {
}, ComponentProto) }, ComponentProto)
} }
export const make_old = < export const makeUntraced: make.Gen = (...pipeables: readonly [any]) => Object.setPrototypeOf({
Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, body: Effect.fnUntraced(...pipeables),
P extends {} = {}, displayName: !String.isEmpty(pipeables[0].name) ? pipeables[0].name : undefined,
>(
body: (props: P) => Generator<Eff, React.ReactNode, never>,
options?: make.Options,
): Component<
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never,
P
> => {
const displayName = !String.isEmpty(body.name) ? body.name : undefined
return Object.setPrototypeOf({
body: options?.untraced
? Effect.fnUntraced(body)
: displayName
? Effect.fn(displayName)(body)
: Effect.fn(body),
displayName,
finalizerExecutionMode: options?.finalizerExecutionMode ?? "sync",
finalizerExecutionStrategy: options?.finalizerExecutionStrategy ?? ExecutionStrategy.sequential,
}, ComponentProto) }, ComponentProto)
}
export const withRuntime: { export const withRuntime: {