Skip to content

Selectors

The examples run inside an active graph.

createSelector source is createLookup with affected = fun prev next -> [ prev; next ]: Get key is true for the selected key and false for every other. A selection change wakes only the readers of the previous and the next key.

let selected = createSignal 1
let isSelected = createSelector (fun () -> selected.Value)
selected.Value <- 3
[ for k in 1..4 -> k, isSelected.Get k ]
[(1, false); (2, false); (3, true); (4, false)]
Tests covering this behaviour

Pinned by createSelector reports membership and wakes only the two ends and only the affected keys are recomputed (Lookups.fs).

Move the selection from 1 to 2. Only those two membership values change; the reader for key 3 stays quiet.

Edit this page