Readme Index
- Installation
- StoreFlow Core Api
- SideEffects
- Subscriber Aware StoreFlow
- Jetpack Compose Support
- Unit Test Support
Jetpack Compose Support
Module: com.episode6.redux:compose:1.0.1
The :compose
module includes a StoreFlow.collectAsState()
convenience method for use in Jetpack Compose (both android and kotlin multi-platform). This removes the need for the caller to specify a default value, since a StoreFlow includes a stable initialValue that is used. We also include a version of the method that takes a transform lambda as a parameter, to collect only part of the State.
Example:
@Composable fun storeFlowExample(store: StoreFlow<TrafficLightState>) {
// collect the entire state
val entireState: TrafficLightState by store.collectAsState()
// only collect a part of the state
val greenLight: Boolean by store.collectAsState { it.green }
}