Skip to content

Instantly share code, notes, and snippets.

@rygelouv
Last active April 26, 2022 14:41
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 rygelouv/f14d9027d8c8aedc58ba966de8a87af4 to your computer and use it in GitHub Desktop.
Save rygelouv/f14d9027d8c8aedc58ba966de8a87af4 to your computer and use it in GitHub Desktop.
class MoviesActivity : ComponentActivity() {
private val viewModel by viewModels<MoviesViewModel>()
private val actionChannel = Channel<MoviesAction>()
private fun actions(): Flow<MoviesAction> = actionChannel.consumeAsFlow()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
actions().onEach(viewModel::processAction).launchIn(lifecycleScope)
setContent {
MoviesAppTheme {
Scaffold(
...
) {
MovieScreenContent(
uiState = viewModel.uiState,
actionChannel = actionChannel
)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment