Kurounin / Pagination

This package allows you to paginate the subscriptions over meteor's collections. It can be used in a Blaze template or in ReactJS.
MIT License
56 stars 22 forks source link

Can the pagination be initialized to display the last page? #95

Closed carlosalvidrez closed 4 years ago

carlosalvidrez commented 5 years ago

Hi, wondering if it is possible to instantiate the client pagination object to start at the last page.

I'm having trouble right now because it loads at page 1, then I get the number of pages, and then I set the object's currentPage to totalPages, but it gets stuck in an infinite loop.

Any help will be appreciated. Thanks!!

Kurounin commented 4 years ago

You can't instantiate to the last page, since you first need to make a subscription to the server to get the number of pages. Why don't you sort in reverse so there's no need to start at the last page? To switch to the last page after the first init, you could keep a local variable (isInit = true) and after the subscription is done and you have the total number of pages modify it (isInit = false) together with setting the currentPage and any subsequent for isInit will fail so currentPage won't be modified, thus ensuring there won't be a loop.

carlosalvidrez commented 4 years ago

Thank you, I will give that a whirl this week. I truly appreciate it.