Handle pagination in recompose#76
Conversation
Pagination
add import effect
new pagination handle
… the bad behaviour of ReachedEnd)
| @@ -0,0 +1,5013 @@ | |||
| # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | |||
There was a problem hiding this comment.
Delete this file because we use npm
| [`${action.target}TotalItems`]: Number(selector(action).meta.totalItems) | ||
| }) | ||
| }) | ||
| : mergeState(state, { |
There was a problem hiding this comment.
I think you can call onSuccess directly here
| ? mergeState(state, { | ||
| [`${action.target}Loading`]: false, | ||
| [`${action.target}Error`]: null, | ||
| [`${action.target}`]: |
There was a problem hiding this comment.
| [`${action.target}`]: | |
| [action.target]: |
| Number(selector(action).meta.currentPage) === 1 | ||
| ? selector(action).list | ||
| : state[action.target].concat(selector(action).list), | ||
| [`${action.target}TotalPages`]: Number(selector(action).meta.totalPages), |
There was a problem hiding this comment.
I think you need to modify completeState as well, in order to add all these new targets
| postBehavior(dispatch, response); | ||
| if (determination(response)) { | ||
| if ( | ||
| (paginationAction && paginationNotHasFinished && determination(response)) || |
There was a problem hiding this comment.
Mmm I don't understand this part
| target: ticketsTarget, | ||
| paginationAction: true, | ||
| refresh: newPagination, | ||
| reducerName: "tickets", |
There was a problem hiding this comment.
Having to specify the reducer you are in doesn't look good to me.
|
Hola @felire ! Me parece muy copada la idea. Me hace acordar un poco a (esto)[https://react-query.tanstack.com/guides/paginated-queries].
De todas formas voy a pedirle a los otros chicos de react-native que lo miren para que den una opinión, ya que ellos son los que la usan en el día a día. La forma de poner "al día" este PR si querés hacerlo es
|
| meta: { | ||
| totalPages, | ||
| currentPage, | ||
| totalItems // This last item is not necessary but maybe you will need it for something specific. |
| @@ -1,5 +1,11 @@ | |||
| import mergeInjections from '../mergeInjections'; | |||
|
|
|||
| const checkPaginationNotHasFinished = (state, pageSelector) => | |||
There was a problem hiding this comment.
This name is a little bit confusing. Would you like to name it using the positive case ?
|
@marianozicavo I won't have time to complete this the following weeks and months. If anyone from wolox want to complete feel free fo fork my branch and work from there. |
Pagination Actions
You will have to write actions with the following params (only if you want to build a paginationAction, if you don't want that, write actions like always):
Your service will receive an object with the nextPage prop.
Example of using:
If you want to send more info to your service, your
payloadwill have to return an object, not a single value. (Only if you are using paginationActions)