Comments (9)
I did some more tests, it only happens after also changing from @Parcable
to @Serializable
, I will make a reproducer.
Using 3.0.0-alpha05, it works again, although I had to add @Serializable
to WebHistoryController
, in case that matters.
3.0.0-alpha01 also works.
Thanks for the fast response!
from decompose.
There should be no behaviour change, though there could a bug that was fixed. Could you please provide more information? In particular, what you mean by "the main instance keeper seems to be inherited to child components"?
Also a reproducer (a project, a test, etc) would be very helpful.
from decompose.
Looking at the changes between 2.1.4 and 2.2.2, I don't see anything that could affect the behaviour.
from decompose.
Glad it works on the latest versions. Though, it would be still nice to double check what's the issue.
from decompose.
I found the reason for the problem.
Have a look at this sample project, branch decompose-2.2.2.
It has a root component with 3 child components. One child component's config has a value "token". When this config is not a data class
, this config is always treated as new on recreation regardless of its value and therefore a new InstanceKeeper
is created. If it is a data class
, the config is compared correctly with the old config, e.g. the same value means the config is not new and therefore the old InstanceKeeper
is kept alive. I think the comparison of configs with non data classes in decompose 2.2.2 does not work correctly, but works again with 3.0.0+.
The associated test is here:
I hope this helps :-)
from decompose.
Thank you very much for the detailed explanation! Now it's al clear. This behaviour is by design, and it was like this from the very beginning. I'm surprised that it worked in some versions. This is documented - configurations must "Correctly implement equals() and hashCode() methods".
from decompose.
I just checked my stable branch and this is actually working. It makes sense that equals() and hashCode()
should be implemented, but I wonder if comparing the serialized data is an option.
sealed interface Config : Parcelable {
@Parcelize class Case(val token: String) : Config
@Parcelize data object Scanner : Config
@Parcelize data object History : Config
@Parcelize data object About : Config
}
from decompose.
Yes, both kotlin-parcelize
and kotlinx-serialization
handle object
classes just fine - there is always just one instance, and so it's always equal. The new data object
also generates equals
and hashCode
functions, just like data class
. So it also works with JVM Serialization, though not used by Decompose. Anyway, data object
is the safest and preferable way.
from decompose.
Closing this for now. Feel free to reopen if there are any issues or questions.
from decompose.
Related Issues (20)
- Helpful tip for childSlot HOT 9
- Some Problem in decompose = "3.0.0" and decompose-router = "0.5.1", kotlin = 2.0.0-RC3 HOT 2
- Add StackNavigator#popToFirst extension
- Update dependencies HOT 2
- NotOnMainThreadException false-positive HOT 1
- Improve docs for StateKeeper and InstanceKeeper HOT 1
- iOS: Error when updating to 3.1.0 (PageScrollAnimation) HOT 11
- Support forward navigation HOT 2
- Document in replaceAll KDocs that it doesn't recreate the components kept in the stack
- How to organize root component and it's children in a way their lifecyle will be managed automatically? HOT 2
- Same arguments result in duplicate HashCode in Component Configurations HOT 2
- close the application
- IllegalStateException: Another supplier is already registered with the key HOT 7
- Consider renaming `push` to `pushOrThrow` HOT 1
- Compose Multiplatform resources via WebHistoryController HOT 2
- Preventing Unstable Composable Argument
- Promote Child Pages API to stable
- Why does MutableValue not emit distinct values? HOT 2
- How to Disable iOS Swipe-Back Gesture on a Specific Page in a Child Stack Navigation Using Decompose HOT 4
- Adaptive Layouts HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from decompose.