voyager
voyager copied to clipboard
multiplatform state restoration
I am using Voyager in a multiplatform project to share screens and screen models and, in order to have state restoration properly working, I followed the guide in the documentation which worked seamlessly. Some of my users reported that this approach is not going to work with the K2 Kotlin compiler because the frontend is run just once on the common code and typealiases are not going to work.
See this issue and this other issue.
Unfortunately Jetbrains it definitely not going to change its compiler for us so we have to find another way. An option would be to pass only strings as screen arguments and deserialize them manually with kotlinx.serialization. Are there any options that come to your mind?
The typealias can just be changed to
actual interface JavaSerializable : java.io.Serializable
The first time you try to reference a type which is a subtype of that interface from common code it breaks everything apparently.
Cannot access "JavaSerializable' which is a supertype of 'X'. Check your module classpath for missing or conflicting dependencies.
Even if client apps can adopt workarounds to avoid non-primitive arguments to screens, since the library is using it internally I expect that unless something gets done we'll have to switch to something else.
We accept suggestion. I will investigate that.
About Kotlinx.serialization and voyager state restauration, this is something I din't have time to write a proof of concept, but it is on my todo list.
There are still some months ahead (but this needs to be considered for the 2024 roadmap anyway). Please consider me in case I can be of any help, I like the library and I would be glad to contribute in some way.
Screen state restoration is broken as of now.
I see the documentation says that users need to restore a state on JVM platforms only but it is not true. The library has to provide an easy way to restore the state on the iOS side too
https://medium.com/swift-india/app-state-restoration-in-ios-1-bbc903f17a46
Moreover, at the moment the approach seems as a something extra and need to be implemented in a manual mode. It does the library not so stunning for new users