import { ProgressEvent } from './request/ProgressEvent'; import { RequestFetch } from './request/RequestFetch'; import { RequestOptions } from './request/RequestOptions'; import { Requestable } from './request/Requestable'; export interface RequestStoreState { /** * Flag that indicates user want to refresh (receive newest) data * * Will cancel any ongoing requests when *true* */ isRefreshing: boolean; /** * Invoke it when you need to handle progress state of request with more accuracy * * By default `progress` will be *``` * 0 before `.fetch()` * 1 after resolve * 0 after reject * ``` */ onProgress: (event: ProgressEvent) => void; /** * Signal for your request, that is should be aborted * * Can be passed directly to axios, fetch and etc */ signal: AbortSignal; } export declare type RequestCreator = (args: A, state: RequestStoreState) => Promise; export declare class RequestStore implements Requestable { #private; private createRequest; private cancellable?; private start; private onErrorCallback?; isLoading: boolean; /** * Indicates whether the request is currently refreshing * * Pass `isRefresh: true` to the `fetch` method to trigger a refresh. */ isRefreshing: boolean; /** * *undefined* - when request not called yet * * *null* - when request called but not finished * * *true* - when last call of request finished with success and have no errors * * *false* - when last call of request finished with error */ isSuccess: boolean | undefined | null; /** * The error that occurred during the request, if any * * This error will be cleared when a new request is made. */ error: E | undefined; /** * The same as {@link error}, but cleared only after successful request or on {@link clear} */ stickyError: E | undefined; value: R | undefined; progress: number; fetch: RequestFetch; clear: () => void; cancel: () => void; constructor(createRequest: RequestCreator, options?: RequestOptions); }