-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
Hello, i am playing with your library , its great , but i have run into an issue that the onDestroy() of InstanceKeeper.Instance is not called when i pop a screen.
Here is my code.
// inside of a composable fun
val viewModel = rememberOnRoute(SettingsViewModel::class) { savedState -> SettingsViewModel(savedState) }
class SettingsViewModel(private val context: RouterContext) : InstanceKeeper.Instance {
init {
Logger.e("init")
context.lifecycle.subscribe(object : Lifecycle.Callbacks {
override fun onCreate() {
Logger.e("onCreate")
super.onCreate()
}
override fun onDestroy() {
Logger.e("onDestroy")
// this@SettingsViewModel.onDestroy() ->i can call onDestroy directly, but this feels hacky
super.onDestroy()
}
override fun onPause() {
super.onPause()
}
override fun onResume() {
super.onResume()
}
override fun onStart() {
Logger.e("onStart")
super.onStart()
}
override fun onStop() {
Logger.e("onStop")
super.onStop()
}
}
)
}
// NOT CALLED WHEN i POP THE SCREEN
override fun onDestroy() {
Logger.e("MAIN onDestroy")
super.onDestroy()
}
}Can you maybe guide me on what i have done wrong ?
Thanks
Metadata
Metadata
Assignees
Labels
No labels