@@ -43,6 +43,11 @@ const ComponentProto = Object.freeze({
|
||||
},
|
||||
} as const)
|
||||
|
||||
const defaultOptions = {
|
||||
finalizerExecutionMode: "sync",
|
||||
finalizerExecutionStrategy: ExecutionStrategy.sequential,
|
||||
} as const
|
||||
|
||||
const makeWithDefaults = (): Component<any, any, any> => Object.assign(
|
||||
Object.setPrototypeOf(function() {}, ComponentProto), {
|
||||
finalizerExecutionMode: "sync",
|
||||
@@ -290,29 +295,38 @@ export const make: (
|
||||
) = (spanNameOrBody: Function | string, ...pipeables: any[]): any => {
|
||||
if (typeof spanNameOrBody !== "string") {
|
||||
const displayName = displayNameFromBody(spanNameOrBody)
|
||||
return Object.assign(makeWithDefaults(), {
|
||||
return Object.setPrototypeOf(
|
||||
Object.assign(function() {}, {
|
||||
body: displayName
|
||||
? Effect.fn(displayName)(spanNameOrBody as any, ...pipeables as [])
|
||||
: Effect.fn(spanNameOrBody as any, ...pipeables),
|
||||
displayName,
|
||||
})
|
||||
}),
|
||||
ComponentProto,
|
||||
)
|
||||
}
|
||||
else {
|
||||
const spanOptions = pipeables[0]
|
||||
return (body: any, ...pipeables: any[]) => Object.assign(makeWithDefaults(), {
|
||||
return (body: any, ...pipeables: any[]) => Object.setPrototypeOf(
|
||||
Object.assign(function() {}, {
|
||||
body: Effect.fn(spanNameOrBody, spanOptions)(body, ...pipeables as []),
|
||||
displayName: displayNameFromBody(body) ?? spanNameOrBody,
|
||||
})
|
||||
}),
|
||||
ComponentProto,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const makeUntraced: make.Gen & make.NonGen = (
|
||||
body: Function,
|
||||
...pipeables: any[]
|
||||
) => Object.assign(makeWithDefaults(), {
|
||||
) => Object.setPrototypeOf(
|
||||
Object.assign(function() {}, {
|
||||
body: Effect.fnUntraced(body as any, ...pipeables as []),
|
||||
displayName: displayNameFromBody(body),
|
||||
}, ComponentProto)
|
||||
}),
|
||||
ComponentProto,
|
||||
)
|
||||
|
||||
const displayNameFromBody = (body: Function) => !String.isEmpty(body.name) ? body.name : undefined
|
||||
|
||||
|
||||
Reference in New Issue
Block a user