Pagination
@ng-frrri/ngxs and @ng-frrri/ngxs-http exposes functions for pagination via PaginatedHttpCollection and a PaginationInterceptor. The current implementation is an endless pagination relying on the server to respond with a Link-header specifying the next page's url in a rel="next" tag.
Should you require a different pagination mechanism, we suggest to look at paginated-collection.state.ts
and write your own implementation.
To get started using pagination, first add the PaginationInterceptor to your AppModule.
Then define your paginated state using the PaginatedHttpCollection decorator or your own implementation of the data layer you want to consume from:
A PaginatedHttpCollection automatically persists the Link header's rel="next" attribute into your state's next property. If you want to get the next page, simply call PostsState.getNext().toPromise()
.
In cases where you need to load all available pages, you can use PostsState.getAll().toPromise()
Last updated