import { queryAdvancedProfile } from './service'; import { Reducer } from 'redux'; import { EffectsCommandMap } from 'dva'; import { AnyAction } from 'redux'; import { AdvancedProfileData } from './data'; export type Effect = ( action: AnyAction, effects: EffectsCommandMap & { select: (func: (state: AdvancedProfileData) => T) => T } ) => void; export interface ModelType { namespace: string; state: AdvancedProfileData; effects: { fetchAdvanced: Effect; }; reducers: { show: Reducer; }; } const Model: ModelType = { namespace: 'BLOCK_NAME_CAMEL_CASE', state: { advancedOperation1: [], advancedOperation2: [], advancedOperation3: [], }, effects: { *fetchAdvanced(_, { call, put }) { const response = yield call(queryAdvancedProfile); yield put({ type: 'show', payload: response, }); }, }, reducers: { show(state, { payload }) { return { ...state, ...payload, }; }, }, }; export default Model;