This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
react-rest-request/target/reducer.d.ts

32 lines
996 B
TypeScript
Raw Normal View History

/// <reference types="react" />
import { ClientResponse } from './client';
export declare type PublicRequestState<R> = Readonly<{
data: R | null;
loading: boolean;
isCalled: boolean;
isCanceled?: boolean;
2021-06-17 22:43:29 +03:00
response?: ClientResponse<R>;
fetchError?: Error;
}>;
export declare type RequestState<R> = PublicRequestState<R> & Readonly<{
prevHeaders?: Record<string, string>;
prevVariables?: Record<string, any>;
prevParams?: Record<string, any>;
}>;
export declare type RequestAction<R> = {
type: 'call';
headers: Record<string, string>;
variables: Record<string, any>;
params?: Record<string, any>;
} | {
type: 'success';
response: ClientResponse<R>;
} | {
type: 'failure';
response: ClientResponse<R>;
} | {
type: 'cancel';
};
export declare type RequestReducer<R> = React.Reducer<RequestState<R>, RequestAction<R>>;
2021-06-17 22:43:29 +03:00
export declare function requestReducer<R>(state: RequestState<R>, action: RequestAction<R>): RequestState<R>;