Skip to main content

Jetpack Compose module

The module provides ContainerHost extensions for easy subscription from Composables.

Including the module

implementation("org.orbit-mvi:orbit-compose:<latest-version>")

Subscribing to a ContainerHost in Compose

Use the method below to subscribe to a ContainerHost in Compose.

The functions safely follow the Composable lifecycle and will automatically subscribe only if the view is at least STARTED.

@Composable
fun SomeScreen(viewModel: SomeViewModel) {
val state by viewModel.collectAsState()

viewModel.collectSideEffect {
when(it) {
...
}
}

SomeContent(
state = state
)
}