Hi, I have found this corner case which I'm not sure how to handle.
Lets say I have a DashboardController, which is only relevant for logged in user, so it asserts user is there, which is correct (in reality this is dagger UserComponent)
I have a single Activity. At activity level I listen for reactive stream of user objects (between activity.onCreate and activity.onDestroy).
If null user is emitted, that means user was logged out; and therefore backstack needs to be reset to LoginController.
I implemented push notification which might log user out from background (deletes the user; which then emits null user, where the activity level listener resets backstack)
However, if app was running - and then put to background - now onSaveInstanceState is called - now logout push arrives, logs out - listeners handles the emit correctly, i.e. sets the LoginController (it only seems this way),
Now,
the process gets killed; user then clicks on the app, process is restarted & activity restored with saveInstanceState bundle; then router backstack is implicitly restored in attachRouter but the router backstack contains the DashboardController (which then asserts the user, which is not true, and crashes the app)
It should contain the LoginController as set per the listener, so this transaction is lost, because it happened onSaveInstanceState.
I understand why, but, is there way around this somehow? Can I somehow add the transaction after onSaveInstanceState called so it gets restored correctly?
(Other than ifing my way around the user assert and somehow clearing the backstack on restoration)
Maybe some way to inspect the to-be restored backstack beforehand?
Hi, I have found this corner case which I'm not sure how to handle.
Lets say I have a DashboardController, which is only relevant for logged in user, so it asserts user is there, which is correct (in reality this is dagger UserComponent)
I have a single Activity. At activity level I listen for reactive stream of user objects (between activity.onCreate and activity.onDestroy). If null user is emitted, that means user was logged out; and therefore backstack needs to be reset to LoginController.
I implemented push notification which might log user out from background (deletes the user; which then emits null user, where the activity level listener resets backstack)
However, if app was running - and then put to background - now onSaveInstanceState is called - now logout push arrives, logs out - listeners handles the emit correctly, i.e. sets the LoginController (it only seems this way),
Now,
the process gets killed; user then clicks on the app, process is restarted & activity restored with saveInstanceState bundle; then router backstack is implicitly restored in
attachRouter
but the router backstack contains the DashboardController (which then asserts the user, which is not true, and crashes the app)It should contain the LoginController as set per the listener, so this transaction is lost, because it happened onSaveInstanceState. I understand why, but, is there way around this somehow? Can I somehow add the transaction after onSaveInstanceState called so it gets restored correctly?
(Other than
if
ing my way around the user assert and somehow clearing the backstack on restoration)Maybe some way to inspect the to-be restored backstack beforehand?
Thanks