-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle pagination in recompose #76
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this file because we use npm
[`${action.target}TotalItems`]: Number(selector(action).meta.totalItems) | ||
}) | ||
}) | ||
: mergeState(state, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[`${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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm I don't understand this part
target: ticketsTarget, | ||
paginationAction: true, | ||
refresh: newPagination, | ||
reducerName: "tickets", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed indentation
@@ -1,5 +1,11 @@ | |||
import mergeInjections from '../mergeInjections'; | |||
|
|||
const checkPaginationNotHasFinished = (state, pageSelector) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
payload
will have to return an object, not a single value. (Only if you are using paginationActions)