CursorProtocol
public protocol CursorProtocol
A type that contains a set of cursors used to identify items and traverse adjacent pages in a cursor-based paging collection.
The CursorProtocol
protocol is tightly linked with the CursorPageable
and CursorPagingCollection
protocols. Cursor-based paging collections depend on a set of cursors
to identify the first and last items in a given page, providing reference points from which to page through a larger list of results, typically sorted in chronological order. The type of cursor used to identify the items depends on the type of items returned in the page. Therefore, types that conform to this protocol must provide an associated cursor type that can be used to uniquely identify themselves within a paging collection.
-
A type that can be used to identify an item in a paging collection.
Declaration
Swift
associatedtype CursorType
-
The key identifying the most recent item in the page.
For paginated results that are sorted in ascending chronological order (i.e., oldest to newest), this identifer can be used to retrieve the next page of items, or—when sorted in descending chronological order (i.e., newest to oldest)—the previous page of items.
Declaration
Swift
var newest: CursorType? { get }
-
The key identifying the least recent item in the page.
For paginated results that are sorted in ascending chronological order (i.e., oldest to newest), this identifer can be used to retrieve the previous page of items, or—when sorted in descending chronological order (i.e., newest to oldest)—the next page of items.
Declaration
Swift
var oldest: CursorType? { get }