msgraph-sdk-javascript
msgraph-sdk-javascript copied to clipboard
PageIterator: matain the state of previous calls
Feature Request
Maintain the state of all previous calls in the PageIterator.
Is your feature request related to a problem? Please describe
We are using the PageIterator to create an "Infinite Scroll" capability on our SPA application. Unfortunately, when iterating, we have to maintain the state of previous calls in a separate array.
Describe the solution you'd like
Expose an array of objects with all the results returned by the PageIterator.
Describe alternatives you've considered
We created a wrapper around the PageIterator to save the previous state of all results in an array.
@plamber Thank you for initiating this request!
This will be an essential improvement to the PageIterator.
I'm curious here. Why do you keep all those items once "processed"?
Hi @sebastienlevert, This is required if you want to create an infinite scroll effect.
For example, you show a list of the first 10 items of a Graph query to a user. The user scrolls down the page and before we are reaching the end of the 10 items we will trigger another query that returns the next 10 items. In REACT, if you want to re-render the page with 20 items, you need to keep the state of the 20 items to have this infinite scroll logic. You do not want to re-execute a query just because the user scrolls up the page.
Hope this clears the use case.
Cheers
Oh makes sense. You don't append 10 new results, you re-render, but with the 20 results. It's an interesting use case!