/**
* Extract an effectful function from the service.
* Useful when a feature is reduced to, or is a composition of, this function.
* JSDoc is lost in the process.
*/
export const extract = <S, I = S>(self: Context.Tag<S, I>) =>
<K extends Exclude<keyof I, '_tag'>>(key: K) => ((...args: any[]) => self.pipe(
Effect.andThen(service => (service[key] as (...args: any[]) => unknown)(...args))
)) as MapReturnType<I[K], $AddRequirement<S>>;
/**
* Extract an effectful function from the service.
* Useful when a feature is reduced to, or is a composition of, this function.
* JSDoc is lost in the process.
*/
export const extract = <S, I = S>(self: Context.Tag<S, I>) =>
<K extends Exclude<keyof I, '_tag'>>(key: K) => ((...args: any[]) => self.pipe(
Effect.andThen(service => (service[key] as (...args: any[]) => unknown)(...args))
)) as MapReturnType<I[K], $AddRequirement<S>>;