observe

fun <INTERNAL_STATE : Any, EXTERNAL_STATE : Any, SIDE_EFFECT : Any> OrbitContainerHost<INTERNAL_STATE, EXTERNAL_STATE, SIDE_EFFECT>.observe(lifecycleOwner: LifecycleOwner, lifecycleState: Lifecycle.State = Lifecycle.State.STARTED, state: suspend (state: EXTERNAL_STATE) -> Unit? = null, sideEffect: suspend (sideEffect: SIDE_EFFECT) -> Unit? = null)(source)

Observe OrbitContainer.externalStateFlow and OrbitContainer.sideEffectFlow correctly on Android in one-line of code. These streams are observed when the view is in Lifecycle.State.STARTED.

In Activities, call from onCreate, where viewModel is an OrbitContainerHost:

viewModel.observe(this, state = ::state, sideEffect = ::sideEffect)

In Fragments, call from onViewCreated, where viewModel is an OrbitContainerHost:

viewModel.observe(viewLifecycleOwner, state = ::state, sideEffect = ::sideEffect)