PaginatedData

public protocol PaginatedData

The paginated data protocol defines a common interface for result types of paginated requests. The properties of the protocol can be leveraged to enable handling paginated requests automatically by observing the provided properties.

Data

  • The actual type of the requested data (usually provided as a field of the top-level JSON).

    Declaration

    Swift

    associatedtype DataType
  • The actual data that is received by the request.

    Declaration

    Swift

    var data: DataType { get }

Page Metadata

  • The index of the current page. By convention, an index of 1 indicates the first page. You will need to overwrite the zeroBasedPageIndex property to return true when you want to use an API where the first page has index 0.

    Declaration

    Swift

    var page: Int { get }
  • The index of the first element of the data (inclusive).

    Declaration

    Swift

    var from: Int { get }
  • to

    The index of the last element of the data (exclusive).

    Declaration

    Swift

    var to: Int { get }
  • The requested number of items on the page. Might be larger than the actual number of elements.

    Declaration

    Swift

    var chunk: Int { get }
  • The total number of elements that are available.

    Declaration

    Swift

    var totalCount: Int { get }
  • The total number of pages that are available given the chunk.

    Declaration

    Swift

    var totalPageCount: Int { get }
  • zeroBasedPageIndex Default implementation

    Whether the first page of the paginated request is indexed with 0. By default, this property is false and indicates that the first page is indexed with 1.

    Default Implementation

    Declaration

    Swift

    var zeroBasedPageIndex: Bool { get }

Synthesized Properties

  • count Extension method

    The number of elements currently returned.

    Declaration

    Swift

    public var count: Int { get }
  • isLastPage Extension method

    Returns whether the returned page of the data is the last page available.

    Declaration

    Swift

    public var isLastPage: Bool { get }