QueryCollection interface

Module @runic-artifex/views in @runic-artifex/views 0.23.0

interface QueryCollection<TRow>

The rows of one query collection for one presentation. Generated clients expose one per collection as client.queries.{name}; framework bindings follow it with useQueryCollection.

Properties

current

readonly current: QueryCollectionSnapshot<TRow>;

No documentation.

Methods

subscribe

subscribe(listener: () => void): () => void;

Calls listener after each change of current, until the returned function is called.

setRange

setRange(start: number, count: number): void;

Shows count rows from start (at most 1,000). Rows it has not loaded become placeholders and are requested from .NET: one request at a time, for the latest range, so fast scrolling sends few requests.

setQuery

setQuery(query: RunicQuery): Promise<void>;

Changes the collection's sort and filter, which is ViewModel state that every presentation shares. Resolves once the state includes it; rejects with a BridgeError (rejected, reason invalid-input) for a query .NET rejects.

indexOf

indexOf(key: string): Promise<number | undefined>;

The position of the row with key in the current query's order, or undefined when no row has it.

locate

locate(key: string): Promise<{
    readonly index: number | undefined;
    readonly version: number;
}>;

The position of the row with key, with the version .NET found it at. A version older than current.version means the query changed meanwhile, and the position belongs to the old one. scrollToKey uses it.

row

row(index: number): QueryRow<TRow>;

The row at any position: loaded, or a placeholder.

retry

retry(): void;

Loads the range again after a failure.

dispose

dispose(): void;

Stops loading; the generated client disposes its collections with itself.