Colton Idle
08/08/2023, 10:38 PM@Composable
fun MyMainScreenInAComposeMultiplatformApp(someGenericClass: Foo = Foo()){
Text(someGenericClass.text)
}
Arkadii Ivanov
08/08/2023, 10:41 PMremember {}
, but still it will be gone if the Composable goes into the back stack, whereas real ViewModel stays.Landry Norris
08/08/2023, 11:20 PM@Composable
fun MainScreen() {
val vm = FooViewModel()
FooScreen(vm)
}
Not that I'd recommend this, but it shouldn't need to recompose if I understand correctly.Colton Idle
08/09/2023, 12:07 AM@Composable
fun MyMainScreenInAComposeMultiplatformApp(){
val vm = remember {Foo()}
Text(vm.text)
}
?Landry Norris
08/09/2023, 12:36 AMColton Idle
08/09/2023, 2:57 AMStylianos Gakis
08/09/2023, 6:54 AMMichael Paus
08/09/2023, 7:53 AMColton Idle
08/09/2023, 11:59 AMJavier
08/09/2023, 1:01 PMViewModel
in the parent one, which can be based on how are you building your app, for example, if you are using navigation-compose, you can decide how your ViewModel
must live based on in which part of the graph you are creating itJavier
08/09/2023, 1:03 PMViewModel
, just pass the state/functions to the screenColton Idle
08/09/2023, 1:03 PMColton Idle
08/09/2023, 1:05 PM@Composable
ScreenAOuter(vm: MyViewModel)
{
ScreenAInner(vm.foo, vm.bar)
}
and then screen A is stateless, no vms passed into it. etc.Colton Idle
08/09/2023, 1:06 PM