Commit 69a9d9bb authored by ι™ˆεΈ…'s avatar ι™ˆεΈ… Committed by niko

Unlimited list to add a special method (#451)

parent c03d59b5
...@@ -10,6 +10,21 @@ export default { ...@@ -10,6 +10,21 @@ export default {
effects: { effects: {
*fetch({ payload }, { call, put }) { *fetch({ payload }, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(queryFakeList, payload);
yield put({
type: 'queryList',
payload: Array.isArray(response) ? response : [],
});
yield put({
type: 'changeLoading',
payload: false,
});
},
*appendFetch({ payload }, { call, put }) {
yield put({ yield put({
type: 'changeLoading', type: 'changeLoading',
payload: true, payload: true,
...@@ -27,6 +42,12 @@ export default { ...@@ -27,6 +42,12 @@ export default {
}, },
reducers: { reducers: {
queryList(state, action) {
return {
...state,
list: action.payload,
};
},
appendList(state, action) { appendList(state, action) {
return { return {
...state, ...state,
......
...@@ -32,7 +32,7 @@ export default class SearchList extends Component { ...@@ -32,7 +32,7 @@ export default class SearchList extends Component {
fetchMore = () => { fetchMore = () => {
this.props.dispatch({ this.props.dispatch({
type: 'list/fetch', type: 'list/appendFetch',
payload: { payload: {
count: pageSize, count: pageSize,
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment