Logo FSBarV1_Archived

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

T

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 * ` for read-after-write queries like `toggleOverlay`.

Functions and values

Function or value Description

create events initial

Full Usage: create events initial

Parameters:
Returns: T

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.

events : IHubEventSink
initial : HubState
Returns: T

current arg1

Full Usage: current arg1

Parameters:
    arg0 : T

Returns: HubState

Read the current aggregate state. Safe from any thread; non-blocking (a single volatile read of the cell).

arg0 : T
Returns: HubState

setActiveTab arg1 arg2

Full Usage: setActiveTab arg1 arg2

Parameters:
Returns: SubmitOutcome

Set the active Hub tab. Always succeeds (every `HubTab` case is valid); emits `HubEvent.ActiveTabChanged`.

arg0 : T
arg1 : HubTab
Returns: SubmitOutcome

setCamera arg1 arg2

Full Usage: setCamera arg1 arg2

Parameters:
Returns: SubmitOutcome

Set the Viewer camera. Validates via `ViewerCamera.validate` (finite components, `Scale ∈ [0.05, 100.0]`); rejection emits no event.

arg0 : T
arg1 : ViewerCamera
Returns: SubmitOutcome

setEncyclopedia arg1 arg2

Full Usage: setEncyclopedia arg1 arg2

Parameters:
Returns: SubmitOutcome

Replace encyclopedia filter / selection. Emits `HubEvent.EncyclopediaSelectionChanged`.

arg0 : T
arg1 : EncyclopediaSelection
Returns: SubmitOutcome

setLobby arg1 arg2

Full Usage: setLobby arg1 arg2

Parameters:
Returns: SubmitOutcome

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.

arg0 : T
arg1 : LobbyConfig
Returns: SubmitOutcome

setSettings arg1 arg2

Full Usage: setSettings arg1 arg2

Parameters:
Returns: SubmitOutcome

Replace the in-memory `HubSettings` snapshot. Emits `HubEvent.HubSettingsChanged`. Does not persist — callers combine this with `HubSettings.save`.

arg0 : T
arg1 : HubSettings
Returns: SubmitOutcome

setVizAttribute arg1 key value

Full Usage: setVizAttribute arg1 key value

Parameters:
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.

arg0 : T
key : string
value : AttributeValue
Returns: SubmitOutcome

setVizConfig arg1 arg2

Full Usage: setVizConfig arg1 arg2

Parameters:
Returns: SubmitOutcome

Replace the entire `VizConfig` (e.g. a preset load or a wire `SetVizConfig` call). Emits `HubEvent.VizConfigChanged` once.

arg0 : T
arg1 : VizConfig
Returns: SubmitOutcome

toggleOverlay arg1 key target

Full Usage: toggleOverlay arg1 key target

Parameters:
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.

arg0 : T
key : OverlayKind
target : ToggleTarget
Returns: SubmitOutcome * bool

updatePresetList arg1 arg2

Full Usage: updatePresetList arg1 arg2

Parameters:
    arg0 : T
    arg1 : string list

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.

arg0 : T
arg1 : string list

Type something to start searching.