Wolf Logan
04/30/2020, 6:41 PMdata class
definitions into the common library But in some cases I have types that encapsulate other, platform-specific types.Casey Brooks
04/30/2020, 6:48 PMKris Wong
04/30/2020, 6:49 PMWolf Logan
04/30/2020, 6:51 PMkotlinx.serialization
in this context? It's the serialisation that I'm most concerned about tying down, since (historically) our team has had bad experiences with JSON contract drift, and I want to offer them a good solid strategy for success hereKris Wong
04/30/2020, 7:02 PMpablisco
04/30/2020, 8:43 PMactual
keyword with different implementations if needed.
One use case I had was country codes. On my model I had just the code and then the country was resolved to a sealed class with a fallback "Unknown" data class (part of the original sealed class) so I was able to bridge the server dato to something typed.
I started originally making custom serializers, but they are not quite there yet for all cases, it was safer to keep things simple 😁
One downside is that the country is resolved at time of usage instead of at time of parsing, however it means that they are lazily initiated so that can also be good, depends on the case. An alternative is to do lazy properties instead of an extension property if it becomes a problem.Wolf Logan
04/30/2020, 8:47 PMpablisco
04/30/2020, 8:56 PM