import { CommandInstance } from "command"; import { ClientResponseErrorType, ClientResponseType, ClientResponseSuccessType } from "client"; import { FetchEffect } from "effect"; import { ExtractError } from "types"; export type FetchEffectLifecycle = "trigger" | "start" | "success" | "error" | "finished"; export type FetchEffectInstance = FetchEffect; export type FetchEffectConfig = { /** * It should match effectKey on the command for which given effect should be triggered. */ effectKey: string; /** * Callback that will be executed when request gets triggered */ onTrigger?: (command: CommandInstance) => void; /** * Callback that will be executed when request starts */ onStart?: (command: CommandInstance) => void; /** * Callback that will be executed when response is successful */ onSuccess?: (response: ClientResponseSuccessType, command: CommandInstance) => void; /** * Callback that will be executed when response is failed */ onError?: (response: ClientResponseErrorType>, command: CommandInstance) => void; /** * Callback that will be executed when response is finished */ onFinished?: (response: ClientResponseType>, command: CommandInstance) => void; };