Any trick to retrieving a viewModel instance in th...
# compose
k
Any trick to retrieving a viewModel instance in the
MainActivity
class? I tried
by viewModels()
but this is creating a new view model instance rather than finding the active one.
c
Your question is neither compose nor Kotlin related. Check the viewmodel‘s lifecycle documentation https://developer.android.com/topic/libraries/architecture/viewmodel#lifecycle
k
sorry… thx.
d
@Chrimaeon Is it not relevant to compose multiplatform? Or is there a better channel to discuss that sort of question?
c
How to handle a ViewModel in an Activity? That’s plain Android and should not be discussed in a slack workspace by JetBrains.
d
I mean, its relevant to Compose Desktop, which is not "plain Android"
c
No, they are asking how to handle the ViewModel in a Activity. There is no Activty in compose desktop.
d
Ah, I see. The line can be really blurry to someone new to the ecosystem.