useFeatureSelection
The selected set as the ui shows it: the host's FeatureSelection store,
resolved against the layers, with the select-mode flag and one message to
the live region for each change a person makes.
This is a function exported by @mapcairn/map, checked against version 0.2.0.
Signature
import { useFeatureSelection } from "@mapcairn/map";
function useFeatureSelection(layers: DataLayers, options?: UseFeatureSelectionOptions): FeatureSelectionState | null;
Description
Call it once, in the host beside useDataLayers, and hand the result down
with SelectionProvider: its state outlives the sheet's sections, which
unmount. It returns null when the host supplies no store, so a host without
one offers no selection.
Parameters
layers(DataLayers)options?(UseFeatureSelectionOptions)
Returns
FeatureSelectionState | null
Remarks
A reference shows its layer's loaded feature, else a snapshot kept
while it was loaded, but only while its layer is on and is a feed layer.
Otherwise it is not shown, and it stays in the store and counts. Turning a
layer off drops nothing and says nothing here: useDataLayers announces
the turning off itself, and its Undo brings the references back. A layer
that a ready catalogue removes is different: it cannot come back by Undo,
so its references are dropped, once and in one message, when the removal
is seen. Nothing is dropped at mount, while the catalogue is loading or
has failed, for a layer the catalogue never listed, or for a reference a
store hydrates later. A change made outside (hydration, a failed save)
updates entries and is not announced. Each message carries the new
total, because the live region replaces a waiting message that is not
kept with a later one when both arrive within THROTTLE_MS of the last
one sent. The refusal of a batch past the limit is assertive, the rest
polite.