@rest-api/react-models
Version:
[](https://www.npmjs.com/package/@rest-api/react-models) [](https://codecov.io/gh/hector7/rest-
35 lines (34 loc) • 1.56 kB
TypeScript
import { Schema, StringOrNumberKeys } from '../Schema';
import { RestModel, UrlCallbackParam } from ".";
export default class ComplexIdRestModel<OptType = any, S extends Schema<any> = any, IdKey extends StringOrNumberKeys<S['RealType']> & StringOrNumberKeys<S['PopulatedType']> & string = any> extends RestModel<OptType, S, IdKey> {
constructor(model: RestModel<OptType, S, any, any, any>, key: IdKey, optSchema: Schema<OptType>, url: UrlCallbackParam<OptType>);
useInvalidate(opts: OptType, id: S["RealType"][IdKey]): () => void;
useInvalidateAll(): () => void;
useFetchByIdIfNeeded(opts: OptType, id: S["RealType"][IdKey]): void;
useGetById(opts: OptType, id: S["RealType"][IdKey]): {
redirect: () => void;
item: S["RealType"] | null;
initialized: boolean;
loading: boolean;
invalidated: boolean;
error: import("../../..").HttpError | null;
};
useFetchByIdPopulatedIfNeeded(opts: OptType, id: S["PopulatedType"][IdKey]): void;
useGetByIdPopulated(opts: OptType, id: S["PopulatedType"][IdKey]): {
redirect: () => void;
populated: true;
invalidated: boolean;
initialized: boolean;
error: import("../../..").HttpError | null;
loading: boolean;
item: S["FullPopulatedType"];
} | {
redirect: () => void;
item: S["PopulatedType"] | null;
loading: boolean;
initialized: boolean;
populated: false;
invalidated: boolean;
error: import("../../..").HttpError | null;
};
}