```rememberSaveable(viewModel) { viewModel.onCreate(); 1 }``` with this I want to call `onCreate()` ...
m
Copy code
rememberSaveable(viewModel) { viewModel.onCreate(); 1 }
with this I want to call
onCreate()
only once and that when
@Composable
is first created. but why is
onCreate()
called more than once? what am missing here? this can be related to other things in the app like DI setup for this etc. but I want to check is there something am missing about
rememberSaveable
c
LaunchedEffect(Unit) { viewModel.onCreate() } ?
m
if user goes to next screen and comes back it will trigger again
c
You can just use the ViewModels init block? thats what i do when i need something to happen just "once"
m
I don’t want side effects 😄
c
yeah. im not in love with init blocks either, but i haven't found another way. hopefully someone else responds here so I can learn something new too. 😄