Hi all :android-wave: , What is the recommended ap...
# compose-android
a
Hi all 👋 , What is the recommended approach for using classes like
Instant
,
LocalDateTime
,
LocalTime
,
LocalDate
, etc in Composables? In domain layer, I had created a
DateUtils
, which I inject into the required classes and use. Can anyone please share what would be a good idea for UI layers, considering testability, maintenance, etc.
j
I dont know which best way, but I do use these things from kotlinx serialization and their serializers in Ktor where only expose it in api layer. In domain layer like repository I often convert into my own sealed interface of all supported date time things. Then in ui layer like compose just using extensions with new kotlinx serialization invariant Locale formatting. Given sealed class only allow a subset of allowed iso formats I want to accept in ui layer.
k
I prefer to do formatting in the ViewModel and expose Strings in the state class
👍 1
a
I was formatting in ViewModel till now as I had UI state in the view model. Now, I am in the process of removing the UI state from the ViewModel. So, I would need to handle the formatting in the Composables.