UNPKG

easy-peasy-classes

Version:

easy-peasy enhanced with classes, full typescript type safety, nested store stuctures and model inheritance

30 lines (29 loc) 1.52 kB
import * as easyPeasy from "easy-peasy"; import { ToStoreType } from "./types"; export declare const modelSym: unique symbol; export declare abstract class ModelBasePure { private [modelSym]; static get obj(): any; } export declare abstract class ModelBase extends ModelBasePure { private _isHoldingChildren; } declare type getStoreState<StoreModel extends object> = () => easyPeasy.State<ToStoreType<StoreModel>>; declare type getStoreActions<StoreModel extends object> = () => easyPeasy.Actions<ToStoreType<StoreModel>>; interface createTypedHooksReturn<Model extends object> { useStoreState: <Result>(mapState: (state: easyPeasy.State<ToStoreType<Model>>) => Result, dependencies?: any[]) => Result; } declare type getStoreStateClone<StoreModel extends object> = createTypedHooksReturn<StoreModel>['useStoreState']; export declare abstract class ModelBasePureTyped<StoreModel extends object> extends ModelBasePure { protected getStateClone: () => this; protected getStoreStateClone: getStoreStateClone<StoreModel>; protected getStoreActions: getStoreActions<StoreModel>; protected getStoreState: getStoreState<StoreModel>; } export declare abstract class ModelBaseTyped<StoreModel extends object> extends ModelBase { protected getStateClone: () => this; protected getStoreStateClone: getStoreStateClone<StoreModel>; protected getStoreActions: getStoreActions<StoreModel>; protected getStoreState: getStoreState<StoreModel>; } export {};