I’d love to show you a library i’ve been working on in the last few months and that our company just recently open sourced. It strives to make it easier to build applications that use paginated web resources.
In my opinion, a pagination library needs to solve these issues:
- If a specific page has already been fetched and there’s no indication that anything changed, don’t fetch that page again
- It must be possible to have different instances for the same data. A list of users for example may show up multiple times on a web application. In this case, all those instances should be able to have their own state, like current page, page size etc.
- Because this is data, it needs to be in the vuex store and it should be possible to work with this data inside of vuex store actions, too.
- If a user navigates a paginated list and changes the page size, we should still be able to show him the same entries as before. E.g. if a user changes to page size 10 from 5, the first entries should be the same - no need to take them back to the first page.
We solved all those points in our library vuex-pagination and i think it enables developers to quickly develop applications depending on paginated resources without having to think about how to store this data etc.
There is also a “range” mode built in, with which you can build cool endless scrolling experiences.
Check it out and please let me know what you think!
Have a good holiday,