Skip to content

Instantly share code, notes, and snippets.

@mattmook
Last active July 20, 2021 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmook/329f745dc02439e3fde857aae4f4a17a to your computer and use it in GitHub Desktop.
Save mattmook/329f745dc02439e3fde857aae4f4a17a to your computer and use it in GitHub Desktop.
The state of MVI on Android - Orbit - PostListFragment
lifecycleScope.launch {
// See https://medium.com/androiddevelopers/a-safer-way-to-collect-flows-from-android-uis-23080b1f8bda
lifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
launch { viewModel.container.stateFlow.collect(::reduce)
launch { viewModel.container.sideEffectFlow.collect(::sideEffect)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment