Skip to content

@sqlrooms/cosmos / useStoreWithCosmos

Function: useStoreWithCosmos()

useStoreWithCosmos<T>(selector): T

Hook to access the Cosmos store with proper typing. Provides type-safe access to the combined project and Cosmos state.

Type Parameters

Type ParameterDescription
TThe type of the selected state slice

Parameters

ParameterTypeDescription
selector(state) => TA function that selects a portion of the state

Returns

T

The selected state portion

Example

typescript
const graph = useStoreWithCosmos(state => state.cosmos.graph);
const isRunning = useStoreWithCosmos(state => state.cosmos.isSimulationRunning);