UNPKG

@rest-api/react-models

Version:

[![npm version](https://img.shields.io/npm/v/@rest-api/react-models)](https://www.npmjs.com/package/@rest-api/react-models) [![codecov](https://codecov.io/gh/hector7/rest-api-react-models/branch/master/graph/badge.svg)](https://codecov.io/gh/hector7/rest-

81 lines (80 loc) 3.29 kB
import { HttpError } from "../.."; import { RequestType } from "../models/ReducerStorage"; export declare const IGNORED_STATUS: number[]; export declare const REQUEST = "REQUEST"; export declare const FAILED = "FAILED"; export declare const INVALIDATE = "INVALIDATE"; export declare const INVALIDATE_ALL = "INVALIDATE_ALL"; export declare const RECEIVE = "RECEIVE"; export declare const REQUEST_ID = "REQUEST_ID"; export declare const FAILED_ID = "FAILED_ID"; export declare const INVALIDATE_ID = "INVALIDATE_ID"; export declare const RECEIVE_ID = "RECEIVE_ID"; export declare const REMOVE_ID = "REMOVE_ID"; export declare const idActions: { invalidateAll: (reducerName: string, optKey?: string) => import("../..").Action<"INVALIDATE_ALL", { reducerName: string; optKey: string; }>; fetchByIdIfNeeded: (reducerName: string, idKey: string, id: string | number, optKey?: string) => import("../..").Action<"REQUEST_ID", { idKey: string; reducerName: string; id: string | number; optKey: string; }>; failedById: (reducerName: string, idKey: string, id: string | number, error: HttpError, optKey?: string) => import("../..").Action<"FAILED_ID", { idKey: string; reducerName: string; id: string | number; error: HttpError; optKey: string; }>; invalidateById: (reducerName: string, idKey: string, id: string | number, optKey?: string) => import("../..").Action<"INVALIDATE_ID", { idKey: string; reducerName: string; id: string | number; optKey: string; }>; receiveById: <T extends unknown>(reducerName: string, data: T, optKey?: string) => import("../..").Action<"RECEIVE_ID", { reducerName: string; data: T; optKey: string; }>; removeById: (reducerName: string, idKey: string, data: any, optKey?: string) => import("../..").Action<"REMOVE_ID", { idKey: string; reducerName: string; data: any; id: any; optKey: string; }>; }; export declare const restActions: { request: (reducerName: string, uri: string, optKey?: string) => import("../..").Action<"REQUEST", { uri: string; reducerName: string; optKey: string; }>; failed: (reducerName: string, uri: string, error: HttpError, optKey?: string) => import("../..").Action<"FAILED", { uri: string; reducerName: string; error: HttpError; optKey: string; }>; invalidate: (reducerName: string, uri: string, optKey?: string) => import("../..").Action<"INVALIDATE", { uri: string; reducerName: string; optKey: string; }>; receive: <Data extends unknown, MetaData extends unknown, IdKey extends keyof Data & string>(idKey: IdKey, reducerName: string, uri: string, items: Data[], metadata: MetaData, optKey?: string) => import("../..").Action<"RECEIVE", { idKey: IdKey; reducerName: string; uri: string; items: Data[]; metadata: MetaData; optKey: string; }>; }; export declare function shouldFetch(request: RequestType<any>): boolean; export declare type ActionUnion<A extends { [actionsCreator: string]: (...args: any[]) => any; }> = ReturnType<A[keyof A]>;