Primitives / foldkit-primitives/state

SelectionSet

const · packages/primitives/src/state/selection.ts:30

Argsnone
Model{ selected: readonly string[] }
MessagesClear, Select { id: string }, Deselect { id: string }, Toggle { id: string }, ReplaceAll { ids: readonly string[] }
Its full type
const SelectionSet: Bundle.Bundle<
  'SelectionSet',
  void,
  { readonly selected: readonly string[] },
  | { readonly _tag: 'Clear' }
  | { readonly _tag: 'Select'; readonly id: string }
  | { readonly _tag: 'Deselect'; readonly id: string }
  | { readonly _tag: 'Toggle'; readonly id: string }
  | { readonly _tag: 'ReplaceAll'; readonly ids: readonly string[] },
  never,
  never,
  never,
  void,
  {},
  {}
>

A selection set as a bundle: the selected ids in the Model, changed one at a time or replaced whole. Order follows first selection; toggling moves a reselected id to the end. Pure logic, no streams.

In the guides