Implementing NGRX library for redux to organize the state of the application in a structured way:
export interface ApplicationState {
adminState: AdminState
}
export interface AdminState {
adminProductCategory: ProductCategoryState;
adminProductVendor: VendorState;
adminProductSubCategory: ProductSubCategoryState;
products: ProductsState;
product: ProductState
}
In the app module:
imports: [
StoreModule.forRoot(reducers, { metaReducers }),
EffectsModule.forRoot([]),
StoreDevtoolsModule.instrument({
maxAge: 25
})
],
Index.ts:
export const reducers: ActionReducerMap<ApplicationState> = {
adminState: AdminState = {
adminProductCategory: AdminProductCategoryReducer,
adminProductVendor: AdminProductVendorReducer,
adminProductSubCategory: AdminProductSubCategoryReducer,
products: ProductsReducer,
product: ProductReducer,
}
};
export const metaReducers: MetaReducer<ApplicationState>[] = [];
An exception occurred:
Type '{ adminProductCategory: (state: ProductCategoryState, action: Action) => any; adminProductVendor: (state: VendorState, action: Action) => any; adminProductSubCategory: (state: ProductSubCategoryState, action: Action) => any; products: (state: ProductsState, action: Action) => any; product: (state: ProductState, acti...' is not assignable to type 'ActionReducer<AdminState, Action>'.
'AdminState' only refers to a type, but is being used as a value here.
Reducer function:
export function AdminProductCategoryReducer(state: ProductCategoryState | undefined, action: Action): any {
return reducer(state, action);
}