0.1.8 #11
@@ -20,34 +20,20 @@ export interface ServiceProps<EH, 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<
|
readonly Live: Layer.Layer<Self>
|
||||||
| Self
|
|
||||||
| (EH extends ErrorHandler.DefaultErrorHandler
|
|
||||||
? ErrorHandler.DefaultErrorHandler
|
|
||||||
: never)
|
|
||||||
>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Service = <
|
export const Service = <
|
||||||
EH = ErrorHandler.DefaultErrorHandler,
|
EH = ErrorHandler.DefaultErrorHandler,
|
||||||
HandledE = never,
|
HandledE = ErrorHandler.Error<Context.Tag.Service<ErrorHandler.DefaultErrorHandler>>,
|
||||||
>(
|
>(
|
||||||
props?: ServiceProps<EH, HandledE>
|
props?: ServiceProps<EH, HandledE>
|
||||||
) => (
|
) => (
|
||||||
<Self>(): ServiceResult<Self, 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(
|
(TagClass as Mutable<typeof TagClass>).Live = Layer.succeed(TagClass, {
|
||||||
Layer.provideMerge(
|
|
||||||
Layer.succeed(TagClass, {
|
|
||||||
ErrorHandler: (props?.ErrorHandler ?? ErrorHandler.DefaultErrorHandler) as Context.Tag<EH, ErrorHandler.ErrorHandler<HandledE>>
|
ErrorHandler: (props?.ErrorHandler ?? ErrorHandler.DefaultErrorHandler) as Context.Tag<EH, ErrorHandler.ErrorHandler<HandledE>>
|
||||||
})
|
})
|
||||||
),
|
|
||||||
|
|
||||||
Layer.provideMerge((props?.ErrorHandler
|
|
||||||
? Layer.empty
|
|
||||||
: ErrorHandler.DefaultErrorHandler.Live
|
|
||||||
) as Layer.Layer<ErrorHandler.DefaultErrorHandler>),
|
|
||||||
)
|
|
||||||
return TagClass
|
return TagClass
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user