View as Markdown

API reference: @salmonui/data/json

JsonDataSourceinterface

import type { JsonDataSource } from '@salmonui/data/json';

Also exported from @salmonui/data.

interface JsonDataSource<Row> extends DataSource<Row> {
    readonly mode: 'remote';
    read(request: DataSourceRequest & {
        readonly groupPath: readonly GroupPathSegment[];
    }): Promise<GroupLoadResult<Row>>;
    read(request: DataSourceRequest & {
        readonly parentRowId: RowId | null;
    }): Promise<TreeLoadResult<Row>>;
    read(request: DataSourceRequest): Promise<DataSourceResult<Row>>;
    write(request: WriteRequest<Row>): Promise<WriteResult<Row>>;
    subscribe(listener: (event: DataSourceEvent<Row>) => void): () => void;
    readonly capabilities: Partial<DataSourceCapabilities>;
    invalidate(scope?: 'rows' | 'counts' | 'facets' | 'all'): void;
    canReload(): boolean;
    reload(signal?: AbortSignalLike): Promise<DataSourceResult<Row>>;
    getRows(): readonly Row[];
    getWriteState(): WriteStateSnapshot<Row>;
    subscribeWriteState(listener: (event: WriteStateEvent) => void): () => void;
    dismissConflict(rowId: RowId): void;
    getStats(): Readonly<RunnerStats>;
}
JsonDataSource members (13)
NameSignatureDescription
modereadonly mode: 'remote';
readread(request: DataSourceRequest & { readonly groupPath: readonly GroupPathSegment[]; }): Promise<GroupLoadResult<Row>>; read(request: DataSourceRequest & { readonly parentRowId: RowId | null; }): Promise<TreeLoadResult<Row>>; read(request: DataSourceRequest): Promise<DataSourceResult<Row>>;
writewrite(request: WriteRequest<Row>): Promise<WriteResult<Row>>;
subscribesubscribe(listener: (event: DataSourceEvent<Row>) => void): () => void;
capabilitiesreadonly capabilities: Partial<DataSourceCapabilities>;
invalidateinvalidate(scope?: 'rows' | 'counts' | 'facets' | 'all'): void;

Clears cached rows/counts/facets (or everything), cursor chains, infinite blocks, and lazy group loads. Does not notify.

canReloadcanReload(): boolean;

True when no foreground read is in flight.

reloadreload(signal?: AbortSignalLike): Promise<DataSourceResult<Row>>;

Repeats the last foreground read, bypassing the cache.

getRowsgetRows(): readonly Row[];

Rows of the last foreground result, including optimistic edits.

getWriteStategetWriteState(): WriteStateSnapshot<Row>;
subscribeWriteStatesubscribeWriteState(listener: (event: WriteStateEvent) => void): () => void;
dismissConflictdismissConflict(rowId: RowId): void;

Drops a conflict after review.

getStatsgetStats(): Readonly<RunnerStats>;