Skip to content

How to sharing viewmodel between an activity and each navgraph destination #1436

Answered by mikucat0309
mikucat0309 asked this question in Q&A
Discussion options

You must be logged in to vote
@Composable
inline fun <reified T : ViewModel> getActivityViewModel(): T =
    getViewModel(owner = LocalContext.current as ComponentActivity)

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by mikucat0309
Comment options

You must be logged in to vote
3 replies
@mikucat0309
Comment options

@PGautam27
Comment options

@PGautam27
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants