How can i share a instance of a class between two composables in compose multiplatform? I cant make it single
Copy code
fun ScreenOne(){
ScreenOne()
ScreenTwo()
}
fun SubScreenOne(){
val viewModel : MyViewModel by inject() //same instance
}
fun SubScreenTwo(){
val viewModel : MyViewModel by inject() // same instance
}
modules{
factory{ MyViewModel() }
}
I walso wouldnt want to pass it through parameters, if possible
a
André Tessmer
05/12/2023, 5:28 PM
maybe
activityViewModels
can help you?
André Tessmer
05/12/2023, 5:28 PM
not sure how that behaves on composable functions
l
Lucas
05/12/2023, 6:29 PM
From what i searched, that is android only
In android i would need only a sharedViewModel, but in multiplatform its not available