import { ExtractError } from "types"; import { FetchEffectConfig } from "effect"; import { CommandInstance } from "command"; import { ClientResponseErrorType, ClientResponseType, ClientResponseSuccessType } from "client"; export class FetchEffect { constructor(public config: FetchEffectConfig) {} getEffectKey = () => { return this.config.effectKey; }; onTrigger = (command: T) => { this.config.onTrigger?.(command); }; onStart = (command: T) => { this.config.onStart?.(command); }; onSuccess = (response: ClientResponseSuccessType, command: T) => { this.config.onSuccess?.(response, command); }; onError = (response: ClientResponseErrorType>, command: T) => { this.config.onError?.(response, command); }; onFinished = (response: ClientResponseType>, command: T) => { this.config.onFinished?.(response, command); }; }