Skip to content

Instantly share code, notes, and snippets.

@fededri
Created January 26, 2022 03:32
Show Gist options
  • Save fededri/ff7151179785503a1e4b7619c7f92efc to your computer and use it in GitHub Desktop.
Save fededri/ff7151179785503a1e4b7619c7f92efc to your computer and use it in GitHub Desktop.
class MoviesFragment : Fragment() {
private val viewModel: MoviesViewModel by activityViewModels {...}
override fun onCreateView(inflater: LayoutInflater): View = ComposeView(inflater.context).apply {
layoutParams = ...
setContent {
val state by viewModel.observeState().collectAsState()
MoviesListView(state = state, onMovieSelected = { movie ->
viewModel.action(MoviesActions.SelectMovie(movie))
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment