From 69a9d9bb3a1c83602a8659ef6ab47d5d2e13a020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 18 Dec 2017 09:53:05 +0800 Subject: [PATCH] Unlimited list to add a special method (#451) --- src/models/list.js | 21 +++++++++++++++++++++ src/routes/List/SearchList.js | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/models/list.js b/src/models/list.js index 965c6f6d..d047b826 100644 --- a/src/models/list.js +++ b/src/models/list.js @@ -10,6 +10,21 @@ export default { effects: { *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({ type: 'changeLoading', payload: true, @@ -27,6 +42,12 @@ export default { }, reducers: { + queryList(state, action) { + return { + ...state, + list: action.payload, + }; + }, appendList(state, action) { return { ...state, diff --git a/src/routes/List/SearchList.js b/src/routes/List/SearchList.js index dadde8de..910bbee0 100644 --- a/src/routes/List/SearchList.js +++ b/src/routes/List/SearchList.js @@ -32,7 +32,7 @@ export default class SearchList extends Component { fetchMore = () => { this.props.dispatch({ - type: 'list/fetch', + type: 'list/appendFetch', payload: { count: pageSize, }, -- GitLab