View as Markdown

API reference: @salmonui/data-grid/engine

PipelineStageinterface

import type { PipelineStage } from '@salmonui/data-grid/engine';
interface PipelineStage<Row, State = unknown> {
    readonly name: PipelineStageName;
    key(query: DataQuery, state: State): readonly unknown[];
    run(input: RowModelSnapshot<Row>, ctx: StageContext<Row, State>): RowModelSnapshot<Row>;
    update?(input: RowModelSnapshot<Row>, previous: {
        readonly input: RowModelSnapshot<Row>;
        readonly output: RowModelSnapshot<Row>;
    }, delta: RowDelta, ctx: StageContext<Row, State>): RowModelSnapshot<Row> | undefined;
}
PipelineStage members (4)
NameSignatureDescription
namereadonly name: PipelineStageName;
keykey(query: DataQuery, state: State): readonly unknown[];

Inputs besides the row model and compiled columns. The stage re-runs only when the row model identity, the compiled leaf columns, or one of these values (compared with Object.is) changes.

runrun(input: RowModelSnapshot<Row>, ctx: StageContext<Row, State>): RowModelSnapshot<Row>;

Pure. Must not mutate input; return input itself when nothing changes.

updateoptionalupdate?(input: RowModelSnapshot<Row>, previous: { readonly input: RowModelSnapshot<Row>; readonly output: RowModelSnapshot<Row>; }, delta: RowDelta, ctx: StageContext<Row, State>): RowModelSnapshot<Row> | undefined;

Optional incremental path. Called instead of run when the stage key and the compiled leaves are unchanged, every earlier stage was also updated incrementally (or passed its input through), and the source rows changed only by delta since the stage last ran. previous holds the stage's last input and output (indexes in the previous source array). Must return exactly what run(input, ctx) would return, or undefined to fall back to run.