import type { AnyAction , Reducer , Store } from 'redux' ; import { ReduxStateFactory , ReduxDispatchFactory } from 'refun' ; export const injectReducerFactory = < S extends { } , A extends AnyAction > ( store , reducer , StoreContext ) => < SS extends { } , AA extends AnyAction > ( injectedReducer ) => { store . replaceReducer ( ( state , action ) => injectedReducer ( reducer ( state , action ) as any , action ) as any ) ; return { mapStoreState : ReduxStateFactory < SS & S > ( StoreContext ) , mapStoreDispatch : ReduxDispatchFactory < Store < SS & S > > ( StoreContext ) , } ; } ;