import { AppError,EntitySet } from "../types"; export interface CommonState{ loading:boolean; error:Error|ReturnType|null; } export const initializeCommonState = ():CommonState => ({loading:false,error:null}); export const initializeEntityState = ():EntitySet => ({ items:[], ids:[], selected:null, }); export interface CommonStateWithHistory extends CommonState {history:T[];} export const initializeCommonStateWithHistory = ():CommonStateWithHistory => ({ ...initializeCommonState(), history:[], }); export interface CommonStateWithEntities extends CommonState,EntitySet {} export const initializeCommonStateWithEntities = ():CommonStateWithEntities => ({ ...initializeCommonState(), ...initializeEntityState(), });