ErrorHandler refactoring
All checks were successful
Lint / lint (push) Successful in 16s

This commit is contained in:
Julien Valverdé
2025-03-16 03:33:01 +01:00
parent 077816efb6
commit 778ee27795
2 changed files with 29 additions and 25 deletions

View File

@@ -8,18 +8,18 @@ export interface QueryClient<EH, HandledE> {
}
const Id = "@reffuse/extension-query/QueryClient"
const id = "@reffuse/extension-query/QueryClient"
export type TagClassShape<EH, HandledE> = Context.TagClassShape<typeof Id, QueryClient<EH, HandledE>>
export type GenericTagClass<EH, HandledE> = Context.TagClass<TagClassShape<EH, HandledE>, typeof Id, QueryClient<EH, HandledE>>
export const makeGenericTagClass = <EH = never, HandledE = never>() => Context.GenericTag(Id) as GenericTagClass<EH, HandledE>
export type TagClassShape<EH, HandledE> = Context.TagClassShape<typeof id, QueryClient<EH, HandledE>>
export type GenericTagClass<EH, HandledE> = Context.TagClass<TagClassShape<EH, HandledE>, typeof id, QueryClient<EH, HandledE>>
export const makeGenericTagClass = <EH = never, HandledE = never>() => Context.GenericTag(id) as GenericTagClass<EH, HandledE>
export interface ServiceProps<EH, HandledE> {
readonly ErrorHandler?: Context.Tag<EH, ErrorHandler.ErrorHandler<HandledE>>
}
export interface ServiceResult<Self, EH, HandledE> extends Context.TagClass<Self, typeof Id, QueryClient<EH, HandledE>> {
export interface ServiceResult<Self, EH, HandledE> extends Context.TagClass<Self, typeof id, QueryClient<EH, HandledE>> {
readonly Live: Layer.Layer<
| Self
| (EH extends ErrorHandler.DefaultErrorHandler
@@ -35,7 +35,7 @@ export const Service = <
props?: ServiceProps<EH, HandledE>
) => (
<Self>(): ServiceResult<Self, EH, HandledE> => {
const TagClass = Context.Tag(Id)() as ServiceResult<Self, EH, HandledE>
const TagClass = Context.Tag(id)() as ServiceResult<Self, EH, HandledE>
(TagClass as Mutable<typeof TagClass>).Live = Layer.empty.pipe(
Layer.provideMerge(
Layer.succeed(TagClass, {
@@ -45,7 +45,7 @@ export const Service = <
Layer.provideMerge((props?.ErrorHandler
? Layer.empty
: ErrorHandler.DefaultErrorHandlerLive
: ErrorHandler.DefaultErrorHandler.Live
) as Layer.Layer<ErrorHandler.DefaultErrorHandler>),
)
return TagClass