Skip to content
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

How would you handle pagination? #1

Open
JolandaVerhoef opened this issue Feb 9, 2018 · 1 comment
Open

How would you handle pagination? #1

JolandaVerhoef opened this issue Feb 9, 2018 · 1 comment

Comments

@JolandaVerhoef
Copy link

JolandaVerhoef commented Feb 9, 2018

I love you Droidcon NYC presentation! Now I'm trying to slowly move towards your MVI implementation. But I'm stuck trying to implement pagination in one of the data calls. It's hard to keep track of the current page in the stream-way of thinking. Do you have any suggestion on how this would be done in your sample code?

@JolandaVerhoef JolandaVerhoef changed the title How would you handle pagination How would you handle pagination? Feb 9, 2018
@yousuf-haque
Copy link
Owner

Hi @JolandaVerhoef !

That's a really good question! I'd make an intent for loadNextPage, and a property of loadedPages on the state. I would then have the view layer send the intent into the model layer. The Model layer would read that intent, check which pages have already been loaded according to the current state, and I would issue a new call to get the next page and mutate oldState to include adding the new page of results.

As you page, the data on the state itself would grow, and the state would contain the union of all loaded pages. At that point, it would be the view layer's responsibility to show a subset of the loaded pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants