I have a Singleton object for which all the data modifications happen on the main UI Thread (ensured by posting to UI queue). I am a little confused with the idea of freeze on creation. My code seems to work fine (after update to 0.8) , not throwing any InvalidMutabilityException. Is that as expected? Just looking for an understanding of how freeze for Singletons works.
I think this means I should mark it as ThreadLocal, and that would work.
AnaR
07/09/2018, 5:21 PM
Will try the test and see.
AnaR
07/09/2018, 5:39 PM
The singleton is in code shared between Android and iOS. Its not specific to iOS. Perhaps different rules for that?
o
olonho
07/09/2018, 5:39 PM
note that immutability is only enforced on native targets
a
AnaR
07/09/2018, 5:43 PM
It works when running on iOS or Android. It is shared code. So, this immutability only applies if the Singleton is defined in platform-specific implementation?
AnaR
07/09/2018, 5:49 PM
Maybe it works because the Singleton is created by the application code in swift during execution, since that is the first reference to the Singleton, and it is never referred to from the platform-specific module in Kotlin-native