paging

Paging a query across Task runs: what each page asks for, and whether another page follows.

A paged load runs every page on a NEW Task node (see replaceTask in tasks.bs), so the node cannot be the memory of the query: each page must ask for exactly what the first page asked for. The screen holds the query as a plain AA and hands each run a copy with that page's startIndex. BaseGridView and the TV guide (Schedule) both page this way.

Methods

(static) forPage(query, startIndex) → {object}

The fields for one run of query, starting at startIndex. A copy: query itself is left untouched, so it stays the record of what every page of the load asks for.

Parameters:
NameTypeDescription
queryobject

the load's Task input fields, without startIndex

startIndexinteger

the first item to fetch

Returns:

Task input fields for this page

Type: 
object

(static) nextStart(startIndex, delivered, total) → {integer}

Where the next page starts, or -1 when the load is complete.

A page that delivers nothing ends the load even when total says more exist: the next request would ask for the same startIndex and get the same empty answer, forever.

Parameters:
NameTypeDescription
startIndexinteger

the startIndex of the page that was delivered

deliveredinteger

how many items that page delivered

totalinteger

the server's total for the query

Returns:

the next page's startIndex, or -1

Type: 
integer