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>> {
|
||||
readonly Live: Layer.Layer<
|
||||
| Self
|
||||
| (EH extends ErrorHandler.DefaultErrorHandler
|
||||
? ErrorHandler.DefaultErrorHandler
|
||||
: never)
|
||||
>
|
||||
readonly Live: Layer.Layer<Self>
|
||||
}
|
||||
|
||||
export const Service = <
|
||||
EH = ErrorHandler.DefaultErrorHandler,
|
||||
HandledE = never,
|
||||
HandledE = ErrorHandler.Error<Context.Tag.Service<ErrorHandler.DefaultErrorHandler>>,
|
||||
>(
|
||||
props?: ServiceProps<EH, HandledE>
|
||||
) => (
|
||||
<Self>(): 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, {
|
||||
(TagClass as Mutable<typeof TagClass>).Live = Layer.succeed(TagClass, {
|
||||
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
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user