SelectionController
projects/core/utils/selection-controller.ts
Import#
import { SelectionController } from '@cngx/core/utils'
Description#
Signal-based selection engine. Reads + writes an external
WritableSignal<T[]> — does not own the values.
Memoizes per-value isSelected / isIndeterminate signals by key so
template diff stays stable and consumers can pass the handle into child
components without identity churn.
Index#
Instance Properties#
Methods#
Release retained per-value signal caches. Post-destroy
isSelected(v) / isIndeterminate(v) return a shared
Signal<false> no-op (identity-stable across all calls) so existing
bindings keep working without further memory retention. Writes
(select, deselect, toggle, toggleAll, clear, set) still
mutate values but do not repopulate the caches. Idempotent.
SignalisIndeterminate(value: T)Reactive indeterminate state. With childrenFn: true iff SOME but not
ALL descendants are selected. Without: always returns a shared constant
Signal<false>.
TSignalisSelected(value: T)Reactive membership for a single value. Same value (by keyFn) always
returns the SAME Signal instance — safe to pass into OnPush children
or compare with ===.
T