Pagination
The Collaboration Client uses a custom Paginator
class to help you manage the pagination of entities.
Pagination is the act of only fetching a limited amount of an entity, and then loading more on demand. This helps reduce the initial load of your application, and is essential to scaling an application.
Currently, the following APIs return an instance of Paginator
:
Paginator
class#
The The Paginator
class is returned from certain APIs, and contains just a few functions to help you efficiently fetch data.
next()
#
paginator.next(): Promise<Entity[]>
This function is used to fetch the next set of entities. It can be called multiple times, and each call will load the next X entities, depending on what limit you set.
If there are no more entities left to fetch, it will resolve with an empty array.
.fetched
#
The paginator.fetched
property contains a map of entities that have already been fetched by this instance.
The keys in the map are the entity IDs, and the values are the corresponding entity.