API/PaginatedCollection
PaginatedCollection
src/models/paginated-collection.ts1 public methodsclass
Constructor
Section titled “Constructor”new PaginatedCollection(data: T[], page: number, from?: number, to?: number, total?: number, perPage?: number, prevPageUrl?: string, nextPageUrl?: string, lastPage?: number, firstPageUrl?: string, lastPageUrl?: string)| Parameter | Type | Description |
|---|---|---|
data |
T[] |
— |
page |
number |
— |
from |
number |
— |
to |
number |
— |
total |
number |
— |
perPage |
number |
— |
prevPageUrl |
string |
— |
nextPageUrl |
string |
— |
lastPage |
number |
— |
firstPageUrl |
string |
— |
lastPageUrl |
string |
— |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
data |
T[] |
— |
firstPageUrl |
string |
— |
from |
number |
— |
lastPage |
number |
— |
lastPageUrl |
string |
— |
nextPageUrl |
string |
— |
page |
number |
— |
perPage |
number |
— |
prevPageUrl |
string |
— |
to |
number |
— |
total |
number |
— |
Methods
Section titled “Methods”normalize()
Section titled “normalize()”normalize(selector?: string | function): NormalizedNormalize the collection to a paginated list of ids for state-managed applications.
This method returns a single key object, where the key is the page number and the associated value is an array of ids. Each id is fetched by the collection items, looking up for the “id” key. If an id is supplied to this method, it will be used instead of the default “id” key.
Please note that in case the key doesn’t exist in the collection’s item, a KeyNotFoundError is thrown
| Parameter | Type | Description |
|---|---|---|
selector |
string | function |
— |
Returns — []
