rjrjr / compose-backstack

Simple composable for rendering transitions between backstacks.
Other
504 stars 23 forks source link

Child state saving issues #28

Closed grandstaish closed 4 years ago

grandstaish commented 4 years ago

Hello Zach! 👋

I was playing around with this library yesterday in my app and I ran into a couple issues with your ChildSavedStateRegistry composable function. I think I've solved one of the issues, but I need help with the other.

The first issue was that child values weren't restored across process recreation. There's a rememberSavedInstanceState call with a mutable map, but that map never gets mutated (and so the values never get saved). I think the fix is as straightforward as this.

With the first fix applied, child restoration is mostly working. The one (major) exception is that the currently visible child doesn't get saved/restored. The reason being that we only ever call performSave() for offscreen children. And compose doesn't do any magic to propagate save calls down to child registries. I haven't yet been able to solve this one.

zach-klippenstein commented 4 years ago

Good catch, and thanks for the branch! If you can add some tests and post as a PR I would be happy to merge it. The second part seems doable too, I can't promise I'll have time to look at it this month though but let me know if you figure it out.