How can i share a instance of a class between two ...
# koin
l
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
maybe
activityViewModels
can help you?
not sure how that behaves on composable functions
l
From what i searched, that is android only In android i would need only a sharedViewModel, but in multiplatform its not available