Skip to main content Link Search Menu Expand Document (external link)

usePagination overview

Added in v1.0.0


Table of contents


utils

Pagination (interface)

Signature

export interface Pagination<E, A> {
  readonly page: RefSubject.Computed<number>
  readonly pageSize: RefSubject.Computed<number>
  readonly canGoBack: RefSubject.Computed<boolean>
  readonly canGoForward: RefSubject.Computed<boolean, E>
  readonly paginated: RefSubject.Computed<ReadonlyArray<A>, E>
  readonly viewing: RefSubject.Computed<Viewing, E>

  readonly goBack: Effect.Effect<number>
  readonly goForward: Effect.Effect<number, E>
  readonly goToStart: Effect.Effect<number>
  readonly goToEnd: Effect.Effect<number, E>
}

Added in v1.0.0

PaginationOptions (type alias)

Signature

export type PaginationOptions = {
  readonly initialPage?: number // 0
  readonly initialPageSize?: number // 10
}

Added in v1.0.0

Viewing (interface)

Signature

export interface Viewing {
  readonly from: number
  readonly to: number
  readonly total: number
}

Added in v1.0.0

usePagination

Signature

export declare function usePagination<A, E, R>(
  items: RefSubject.Computed<ReadonlyArray<A>, E, R>,
  options: PaginationOptions = {}
): Effect.Effect<Pagination<E, A>, never, R | Scope.Scope>

Added in v1.0.0