ursus
04/23/2026, 7:12 PMRetainObserver with Nav3 + the retain recipe https://github.com/android/nav3-recipes/blob/main/app/src/main/java/com/example/nav3recipes/retain/RetainActivity.kt
class RetainedPresenterObserver<P : Presenter<*, *>>(val presenter: P) : RetainObserver {
override fun onRetained() {
presenter.onCreate()
}
override fun onEnteredComposition() {
}
override fun onExitedComposition() {
}
override fun onUnused() {
}
override fun onRetired() {
presenter.onDestroy()
}
}
and onRetired is not called while app is on background - and is deferred until app comes back to foreground.
Why?
I find this a big issue - when logout happens on background, say via push message - I need to get rid of everything on backstack thuss clearing all the Presenters & their coroutine scopes - and obviously `onDestroy`s are not getting called; without it flows inside are still collected & doing work after logical logout happens which is not good & gating every action to foreground is not feasible
// Is this a nav3 or compose in general issue?ursus
05/05/2026, 8:48 PM