Jan Skrasek
11/29/2023, 9:19 AM@Serializable
annotation contrary to Swift's interface (Codable
).
I face some unpleasant limitations that would be solvable that way and I'd love to read about it more.Adam S
11/29/2023, 9:22 AMJan Skrasek
11/29/2023, 9:37 AMCLOVIS
11/29/2023, 9:40 AMJan Skrasek
11/29/2023, 9:45 AMserialize(value: Serializable)
• <T> serialize(value: Any, serializer = serializer<T>())
But if I'm building just the private code, having an option to limit the accepted type would be awesome.Jan Skrasek
11/29/2023, 9:47 AMCLOVIS
11/29/2023, 9:47 AMJan Skrasek
11/29/2023, 9:47 AMinterface TrackingEvent : Serializable
would "solve" it quite nicely 🙂Jan Skrasek
11/29/2023, 9:49 AMbut it's also not possible to know at build time which objects are serializable or notYes, I'd consider this an optional feature - if you know this, you can have a build-time check. Anyway, that's why it would be needed to keep the API we have rn. (apart from the bc).
Adam S
11/29/2023, 10:14 AMJan Skrasek
11/29/2023, 10:19 AMinterface Destination : Serializable
. Ideally, I want to expose the Flow<Destination>
from VM - but that wouldn't be enough, I'd have to expose Flow<Pair<Destination, KSerializer<...>>
- that's beginning to be enormously complex and overcomplicated.Adam S
11/29/2023, 10:21 AMArkadii Ivanov
11/29/2023, 1:16 PMKSerializer
explicitly.
E.g. something like the following:
fun <T : Any> someApi(
value: T,
serializer: KSerializer<T>,
...
)
For example the Decompose library uses this approach to save and restore the navigation stack.