composeState
Observes a module's state as a Compose State with an initial value for previews.
The returned State automatically updates when the module state changes, triggering recomposition of any composables that read from it.
Example:
@Composable
fun CounterDisplayPreview() {
val state by composeState<CounterState>(initialValue = CounterState(count = 42))
Text("Count: ${state.count}")
}Content copied to clipboard
Return
Compose State of the requested state type
Parameters
initialValue
The initial state value to use before the store is ready
Observes a module's state as a Compose State.
This is the primary API for observing module state in Composables. The returned State automatically updates when the module state changes, triggering recomposition.
Example:
@Composable
fun CounterDisplay() {
val state by composeState<CounterState>()
Text("Count: ${state.count}")
}Content copied to clipboard
Return
Compose State of the requested state type