WarUI documentation

Grid selector subscriptions

experimental

Track three independent state selections and compare reference equality with shallow equality.

Live example

Expected behavior

Selection, sorting and row-count widgets update only when their selected values change. An unsubscribed widget keeps its final counter.

Source

import { createGrid } from '@warlockcode/warui-core';

const api = createGrid({ rows: [{ id: 1 }], columns: [] });
const remove = api.subscribe(
  state => state.selection.rowIds.length,
  selected => console.log(selected),
  { fireImmediately: true },
);
api.setSelection(['1']);
remove();

API reference

GRID-A01-F04 API
KindNameTypeDescription
Methodselect—Reads a derived value from the last committed snapshot.
Methodsubscribe—Runs the listener after committed changes that pass the equality check.
TypeSubscribeOptions—Supports custom equalityFn and synchronous fireImmediately.