Options
All
  • Public
  • Public/Protected
  • All
Menu

For loading data with infinite, paginated lists

Type parameters

  • T

Hierarchy

  • InfiniteListLoader

Index

Constructors

constructor

Properties

isFinished

isFinished: boolean = false

true when there are no more items to load

itemIds

itemIds: string[] = ...

The IDs of all items in the list. The list doesn't store the actual items, the store does. The list computes its list of items from this list of item IDs, so if you want an item to show up in this list, push the ID to this list, or use the add(item) method

Private Optional lastKey

lastKey: undefined | string

Private Readonly limit

limit: number

Private Readonly loadPage

loadPage: (params: ListParams) => Promise<ListResponse<T>>

Type declaration

Private Readonly messages

messages: { invalidItemWarning: (value: unknown) => string; loaderError: (error: string) => string; missingItemsWarning: (value: unknown) => string; nilValueWarning: () => string }

Type declaration

  • invalidItemWarning: (value: unknown) => string
      • (value: unknown): string
      • Parameters

        • value: unknown

        Returns string

  • loaderError: (error: string) => string
      • (error: string): string
      • Parameters

        • error: string

        Returns string

  • missingItemsWarning: (value: unknown) => string
      • (value: unknown): string
      • Parameters

        • value: unknown

        Returns string

  • nilValueWarning: () => string
      • (): string
      • Returns string

Private Readonly state

state: LoadingState<unknown>

Readonly store

store: ItemStore<T>

Accessors

error

  • get error(): unknown

isDelayed

  • get isDelayed(): boolean
  • true if the list has been loading items for a while (after 500ms by default, not configurable yet)

    Returns boolean

isEmpty

  • get isEmpty(): boolean
  • true when there are no items in the list, and there are no items to be loaded. Use this for displaying empty states

    Returns boolean

isLoading

  • get isLoading(): boolean

items

  • get items(): T[]

Methods

add

  • add(item: T, position?: number | "end"): void
  • Adds the item to the list, and to the store

    Parameters

    • item: T

      The item to be added

    • position: number | "end" = 0

      Where in the list to add the item. Adds at the start by default. Specify "end" to add it to the end of the list.

    Returns void

clear

  • clear(): void

lazyLoad

  • lazyLoad(): Promise<void>

loadFromStart

  • loadFromStart(): Promise<void>

loadMore

  • loadMore(): Promise<void>

remove

  • remove(itemId: string): void
  • Remove an item ID from the list.

    This does not remove the item from the store. If you want to remove the item from the store, call store.remove(itemId), and the item will not show up in this list

    Parameters

    • itemId: string

    Returns void

reset

  • reset(): void

Generated using TypeDoc