UNPKG

worker-fetch-looper

Version:

This is a Fetch looper based on Web Worker and Fetch API

41 lines (40 loc) 1.11 kB
import { TRes } from './types'; export declare const useFetchLooper: ({ timeout, validate, runnerAction, cb, intialState, }: { intialState?: any; timeout: number; runnerAction: { type: string; payload: { url: string; method: 'POST' | 'GET'; body?: any; }; }; validate?: { beforeRequest?: (({ type, payload, }: { type: string; payload: any; }) => boolean) | undefined; response?: (({ res, type }: { res: TRes; type: string; }) => boolean) | undefined; } | undefined; cb?: { onUpdateState?: ((hookResult: { res: TRes; type: string; }) => void) | undefined; onCatch?: (({ err, type, res, }: { err: any; type: string; res: any; }) => void) | undefined; onSuccess?: ((hookResult: { res: TRes; type: string; }) => void) | undefined; } | undefined; }) => { state: any; };