NavKey navTarget parcelable is not enforced
At the moment the NavKey navTarget argument is not enforced to be parcelable. It uses @RawValue to avoid the compiler complaining.
Unfortunately this means it is possible to introduce code that will crash at runtime (there is currently an issue in the newly introduced IndexedBackStack causing a crash when the app is backgrounded.
By adding more constraints to the generics we can ensure that we have compile time safety.
Maybe there are options not to use such a restriction? I would like to pass any models to the screen arguments
Hi @aaudin90, I'm currently looking into something along these lines.
At the moment if you don't make your model parcelable in some manner your app will crash.
Likely the approach in the short term will be a runtime check earlier to avoid things slipping into production
I understand the solution to the current error. I may be wrong, but having to inherit from parcelable makes appyx less usable.
Is it possible to make a second implementation of BaseNavModel that is not tied to parcelable?
Will your Node not be persisting it's routing/state when a configuration change occurs?
You can also get around this by storing the backstack in different stores.
I looked in Decompose, the arguments there must also be Parcelable, but it is possible to disable state saving. And transfer complex models under the annotation @IgnoredOnParcel
Thanks @aaudin90. I'll discuss this with the team, and come back to you :)
I will be waiting for you)
Because of this, :sample:app keeps crashing whenever it goes background with home button or recents button(not back button).
It logs like below.
java.lang.RuntimeException: Parcel: unable to marshal value 0
at android.os.Parcel.writeValue(Parcel.java:1680)
at com.bumble.appyx.core.navigation.NavKey.writeToParcel(Unknown Source:7)
...
@LachlanMcKee, Hi! Have any ideas?)
Perhaps it makes sense to open access to the creation of your own serializers/deserializers, so as not to get tied up in Perselable