Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 754 Bytes

File metadata and controls

29 lines (21 loc) · 754 Bytes
title sidebar_label
Compose
Compose

Tangle supports ViewModel "injection" in composables in a manner very similar to Hilt's navigation/viewModel artifact. It will scope the ViewModel to the composable's NavBackStackEntry.

The viewModels are still able to make use of automatic [SavedStateHandle injection][/savedStateHandle.md], including arguments annotated with @TangleParam.

@Composable
fun MyComposable(
  navController: NavController,
  viewModel: MyViewModel = tangleViewModel()
) {
  // ...
}