model.ts 661 Bytes
Newer Older
陈帅's avatar
陈帅 committed
1
import { AnyAction } from 'redux';
陈帅's avatar
陈帅 committed
2 3
import { EffectsCommandMap } from 'dva';
import { message } from 'antd';
陈帅's avatar
陈帅 committed
4
import { fakeSubmitForm } from './service';
陈帅's avatar
陈帅 committed
5 6 7

export type Effect = (
  action: AnyAction,
陈帅's avatar
陈帅 committed
8
  effects: EffectsCommandMap & { select: <T>(func: (state: {}) => T) => T },
陈帅's avatar
陈帅 committed
9 10 11 12
) => void;

export interface ModelType {
  namespace: string;
陈帅's avatar
陈帅 committed
13
  state: {};
陈帅's avatar
陈帅 committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  effects: {
    submitRegularForm: Effect;
  };
}
const Model: ModelType = {
  namespace: 'BLOCK_NAME_CAMEL_CASE',

  state: {},

  effects: {
    *submitRegularForm({ payload }, { call }) {
      yield call(fakeSubmitForm, payload);
      message.success('提交成功');
    },
  },
};

export default Model;