Skip to content

Commit

Permalink
Merge pull request #3 from felire/pagination
Browse files Browse the repository at this point in the history
new pagination handle
  • Loading branch information
felire authored Jan 15, 2020
2 parents f10a85d + 7e770c9 commit 9bee581
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/completers/completeReducer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function completeReducer(reducerDescription) {
if (
!reducerDescription ||
((!reducerDescription.primaryActions || !reducerDescription.primaryActions.length) &&
(!reducerDescription.modalActions || !reducerDescription.modalActions.length))
(!reducerDescription.modalActions || !reducerDescription.modalActions.length) &&
(!reducerDescription.paginationActions || !reducerDescription.paginationActions.length))
) {
throw new Error('Reducer description is incomplete, should contain at least an actions field to complete');
}
Expand Down
2 changes: 1 addition & 1 deletion src/injections/baseThunkAction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function baseThunkAction({
apiCall: async getState => service(finalSelector(getState())),
determination: response => response.ok,
paginationAction,
pageSelector: { reducerName, target },
pageSelector: { reducerName, target, refresh },
success: (dispatch, response) =>
dispatch({
type: `${type}_SUCCESS`,
Expand Down
3 changes: 2 additions & 1 deletion src/injections/composeInjections/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import mergeInjections from '../mergeInjections';

const checkPaginationNotHasFinished = (state, pageSelector) =>
pageSelector.refresh ||
state[pageSelector.reducerName][`${pageSelector.target}NextPage`] <=
state[pageSelector.reducerName][`${pageSelector.target}TotalPages`];
state[pageSelector.reducerName][`${pageSelector.target}TotalPages`];

function composeInjections(...injections) {
const injectionsDescription = mergeInjections(injections);
Expand Down

0 comments on commit 9bee581

Please sign in to comment.