HubStateStore Module
Central, authoritative state store for the Hub UI (feature 040). Every user-facing action — active-tab swap, Viewer camera pan/zoom, lobby edit, `VizConfig` change, encyclopedia selection, preset list invalidation, settings change — routes through this module. Both the local GUI (tab files under `FSBar.Hub.App`) and the gRPC handlers (`ScriptingHub`) read and write the same cell, so the two surfaces can never drift. Every successful mutation publishes exactly one `HubEvent` through the supplied `IHubEventSink`, powering both local redraw and the remote `StreamHubStateEvents` fan-out. Concurrency model: single `HubState` reference updated via `Interlocked.CompareExchange`. Under contention the loser re-reads and retries up to 3 times before returning `Rejected "write contention"`. This matches the FR-015 / data-model.md §HubStateStore atomic-LWW guarantee.
Types
| Type | Description |
|
Opaque handle over the atomic state cell. Created once per
Hub process by `create`. All mutator helpers below take a `T`
and return either the resulting `SubmitOutcome` (no payload) or
a compound `SubmitOutcome * |
Functions and values
| Function or value |
Description
|
|
Allocate a new store seeded with `initial`. The supplied `IHubEventSink` is retained for the lifetime of the store and receives every `HubEvent` triggered by a successful mutator call.
|
|
|
|
Set the active Hub tab. Always succeeds (every `HubTab` case is valid); emits `HubEvent.ActiveTabChanged`.
|
|
Set the Viewer camera. Validates via `ViewerCamera.validate` (finite components, `Scale ∈ [0.05, 100.0]`); rejection emits no event.
|
Full Usage:
setEncyclopedia arg1 arg2
Parameters:
T
arg1 : EncyclopediaSelection
Returns: SubmitOutcome
|
Replace encyclopedia filter / selection. Emits `HubEvent.EncyclopediaSelectionChanged`.
|
|
Replace the Setup-tab lobby snapshot. Emits `HubEvent.LobbyChanged`. Callers gate the Lobby-editable precondition externally (via `SessionManager.IsLobbyEditable`) — this mutator does not re-check.
|
|
Replace the in-memory `HubSettings` snapshot. Emits `HubEvent.HubSettingsChanged`. Does not persist — callers combine this with `HubSettings.save`.
|
Full Usage:
setVizAttribute arg1 key value
Parameters:
T
key : string
value : AttributeValue
Returns: SubmitOutcome
|
Apply a single-attribute change via a `ConfigDescriptors` key. Emits `HubEvent.VizAttributeChanged` with old + new values when the key resolves. Returns `Rejected "unknown key: ..."` for unknown keys.
|
|
Replace the entire `VizConfig` (e.g. a preset load or a wire `SetVizConfig` call). Emits `HubEvent.VizConfigChanged` once.
|
Full Usage:
toggleOverlay arg1 key target
Parameters:
T
key : OverlayKind
target : ToggleTarget
Returns: SubmitOutcome * bool
|
Flip / set an overlay toggle. Returns both the submit outcome and the new effective state; emits `HubEvent.VizAttributeChanged` with the corresponding descriptor key when the mutation applies.
|
|
Replace the cached preset-name list. Facade-only (no validation). Does NOT emit a `HubEvent` — the `PresetSaved` / `PresetDeleted` events from the preset facade already convey the change; this helper is the store-side cache refresh path.
|
FSBarV1_Archived