Skip to content

Instantly share code, notes, and snippets.

@fededri
Created January 26, 2022 03:32
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 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