@rest-api/react-models
Version:
[](https://www.npmjs.com/package/@rest-api/react-models) [](https://codecov.io/gh/hector7/rest-
52 lines (51 loc) • 1.88 kB
TypeScript
import { ActionUnion, HttpError } from "../..";
import { idActions, restActions } from "../actions";
export declare type RequestType<T> = {
didInvalidate: boolean;
isFetching: boolean;
lastUpdated: Date | null;
error: HttpError | null;
result: T | null;
initialized: boolean;
};
export declare type RestApiReducerType<Item, MetaData, Key extends keyof Item & string> = {
searchs: {
[url: string]: RequestType<{
ids: (Item[Key])[];
metadata: MetaData;
}>;
};
derived: {
[modelName: string]: {
[key: string]: RestApiReducerType<Item, MetaData, any>;
};
};
ids: {
[key: string]: {
[id: string]: RequestType<Item>;
};
};
};
export declare type ApiReducerType<T> = {
[queryString: string]: RequestType<T>;
};
export declare const reducers: {
[key: string]: RestApiReducerMap<any, any, any>;
};
export declare type ReducerType = {
[key: string]: RestApiReducerType<any, any, any> | ApiReducerType<any>;
};
export declare type RestApiReducerMap<Item, Metadata, Key extends keyof Item & string> = (state: RestApiReducerType<Item, Metadata, Key> | undefined, action: ActionUnion<typeof idActions> | ActionUnion<typeof restActions>) => RestApiReducerType<Item, Metadata, Key>;
export default class ReducerStorage {
static storage: ReducerStorage;
static getInstance(): ReducerStorage;
private reducers;
static getReducerName(): string;
static addBasicIdReducer(modelName: string, id: string): void;
static addComplexReducer(modelName: string, reducerName: string): void;
private getReducerByModelName;
private get reducer();
static get generalReducer(): import("redux").Reducer<import("redux").CombinedState<{
[x: string]: any;
}>, import("redux").AnyAction> | ((state: any) => any);
}