export generated function as a Reducer (AOT)
montella1507 opened this issue · 0 comments
Hello everyone,
i would like to ask you if you know how to succesfully export generated reducer:
i have my own reducer generator with fluent API and final method build() which returns a reducer itself, so the usage is like:
`
// reducer.ts
export const patientInfoReducer : (state, action) => CommonDataAppmodel = new TypedReducer<CommonDataAppmodel, PatientInfoActions>(initialState)
.case(PatientInfoActionTypes.PATIENT_INFO_READY,
(state, action) => {
return action.payload.success ?
{ data: action.payload.data, error: false, loading: false}
: { data: {}, error: true, loading: false};
})
.case(PatientInfoActionTypes.LOAD_PATIENT_INFO,
() => ({ data: initialState.data, error: false, loadng: false}))
.case(GlobalDataActionTypes.RESET_PATIENT_DATA,
() => initialState)
.build();
`
return type of build() method is reducer:
(state, action) => CommonDataAppmodel<UserModel>
however if i want to use in in AOT build:
`
// index.ts
export const reducers: ActionReducerMap = {
patientInfo: patientInfoReducer
};`
i cant and i will get error because "calling functions is not suported, use exported... ".