-
Notifications
You must be signed in to change notification settings - Fork 241
Should Flow trigger a State save on lifecycle events? #181
Comments
I opened the referenced issue, and I personally would vote for it, primarily because currently if you put the app to the background and bring it to foreground, then a Essentially, when the |
I came here to log this exact issue. Really pleased to see you have it tracked for the beta. To elaborate more, the issue I'm facing is that when I background the app, then restore the app to the foreground, my |
If REPLACE erases your viewstate, then your dispatcher logic does not preserve the state of removed objects properly. After all, you will need to handle the same scenario on configuration change (rotation). |
Hmm. But when you background the app, the key dispatcher doesn't get called, so you can't call save() on the hierarchy. Then when the REPLACE call happens, the incomingState has a null viewState and therefore it can't be restored. Or am I missing something here? Note that my app functions fine on configuration changes because save/restore are called by the system. |
Ah, right, I remember now. This is why I did this: https://github.com/Zhuinden/flowless/blob/master/flow/src/main/java/flow/ForceBundler.java And called this on the root container in |
That works, so thanks @Zhuinden, I'll use this workaround/hack until this issue is resolved |
Currently it does not-- state can only be saved and restored during a traversal. It does seem like we'd want this, so that we save/restore state uniformly for the current key when appropriate lifecycle events occur.
The text was updated successfully, but these errors were encountered: