model.js
502 Bytes
import { queryFakeList } from './service';
export default {
namespace: 'BLOCK_NAME_CAMEL_CASE',
state: {
list: [],
},
effects: {
*fetch({ payload }, { call, put }) {
const response = yield call(queryFakeList, payload);
yield put({
type: 'queryList',
payload: Array.isArray(response) ? response : [],
});
},
},
reducers: {
queryList(state, action) {
return {
...state,
list: action.payload,
};
},
},
};