How can I change number of records when using nextPage() for LiveCollection?

In my case, I want to get the last 3 comments. Then if the list has more comments, I want to get next 10 comments.

collection.current = CommentRepository.queryComments({
      referenceType: 'post',
      referenceId: id,
      last: 3,

By using pagination, collection.current.nextPage();, is it possible to pass recordPerPage to get the next list with new limitation?

Any suggestion or help is much appreciated.

1 Like


Could you please describe the user journey for a better understanding of why initially getting last 3 comments, then will get 10 comments for the next page. And also what if it has more comments after loading the next 10 comments?

1 Like

@stevenamity lets me add more for the case,

we would like to show 3 comments due to the space on mobile then we will have a button load more on the bottom of the comment section to fetch more 10 older comments which will append in the same section.

we also rely on hasMore to indicate showing of load more button.

It like infinite scroll loading but we have a button to trigger the fetch instead of the scrolling.

Thank you.


Thanks for the details. currently there is no native way to change the item-per-page on the fly. But would it be possible if go with this approach instead:

Purpose of loading 3 initially: limited area on mobile, so just to show 3 and validate users’ interest
Purpose of loading more: if the user is interested in the comment and want to see more, they will click “load more” and repeat until the end

In order to provide the best user experience when they click “load more” for the first time, it’ll be great if the data is already ready so user don’t need to wait. WIth that being said, what if you set 13 for the pagination, but only show 3 items on the UI and hide 10 in the background, and when user clicks “load more” for the first time, simply display the other 10 comments.

it will reduce the API calls largely because most users will stop clicking “load more” button after they see the 1st page, and even if they click the “load more” again, it will call the API and load another 13 comments (rarely users will count how many comments returned this time)

and since the comments are simply text, so 13 items in a call will only increase a tiny size in the response

1 Like