import type { Action , PreloadedState } from 'redux' ; import type { GenericState , StoreConfig } from './types' ; import { configureStore } from './configure-store' ; export class StoreManager < S extends GenericState , A extends Action > { constructor ( private readonly config ) { } public updatedInitialState = async ( excludeUncached ? , req ? ) : Promise < S > => { let updatedState = this . config . initialState ?? { } ; if ( this . config . cachedData ) { updatedState = ( await this . config . cachedData ( { initialState : updatedState , variables : { } } , req ) ) . initialState ; } if ( this . config . uncachedData && excludeUncached !== false ) { updatedState = ( await this . config . uncachedData ( { initialState : updatedState , variables : { } } , req ) ) . initialState ; } return updatedState as S ; } ; public getReduxStore = async ( initialState ? ) => { return configureStore ( ( initialState ?? this . config . initialState ) as unknown as PreloadedState < S > , this . config . reducers ) ; } ; }