UNPKG

@octopusdeploy/design-system-components

Version:
25 lines (24 loc) 1.25 kB
export interface AsyncList<T> { /** Gets the ID of an item */ getItemId: (item: T) => string; /** Gets an item from any items that have been loaded */ getItemById: (id: string) => T | undefined; /** The items that have currently been loaded for the list */ loadedItems: T[]; /** Whether the list is currently loading */ isLoading: boolean; /** The error that occurred if loading failed */ error: Error | null; /** If the list has more data to be loaded, this can be used to start loading it. Mutually exclusive with `refresh`. */ loadMore?: () => void; /** Sets the filter value for the list items */ setFilterText: (text: string) => void; /** * Reloads the list's items from its source. When provided, a `Select`/`MultiSelect` backed by * this list renders a refresh button that calls it. Return a promise that resolves once the * reload completes (or rejects if it fails) and the select will announce the outcome when it * settles; a plain `void` return also works (the outcome is announced immediately). Omit when * the list cannot be refreshed (e.g. a static, in-memory list). Mutually exclusive with `loadMore`. */ refresh?: () => void | Promise<void>; }