In my app I have a ktor wrapper that interacts wit...
# compose-android
z
In my app I have a ktor wrapper that interacts with an API. I found that the data classes that get returned by my ktor wrapper are unstable unless I setup the compiler. I was hoping I could eventually extract the API portion from my app and provide it as a separate library. But with the android dependency also depending on compose, that would be a problem for someone who is using view based UI or something else. Is there some solution to this issue?
a
The data classes might eventually be a state to the UI (basically wrapped into a state by the consumer). Why do you want to make them stable?
z
Well they result in my composables which use the classes to become unstable, which isn't ideal
s
Since afaik there’s no way as a user that you can define that something is stable if it comes from a separate library, it may be that your best bet is to still apply the compose compiler on that module to get this inference. You could maybe use the multiplatform one from Jetbrains too to not make that module be an Android only one. Not even sure if this would work at all, especially if this is then served as a library, but if you really want to do it it’d be worth a try I think 🤷
c
interesting question! 1. I've shipped a few apps to prod that were 100% compose and never used the @Stable annotation. idk y i even bring it up. but i guess i just wanna point out that having things be stable isn't a requirement and things def work performantly without it. 2. i would think if you made a separate networking module you would still have another model that mapped from your network to your domain/view and you'd want that to be stable?
a
Tbh, your data classes is immutable if the public properties are
val
and you override the
equals
function, as that is what compose uses to determine change. If your class agrees to these conditions a function can be marked
skippable
by the compose compiler.
s
Tbh, your data classes is immutable if the public properties are val and you override the equals function, as that is what compose uses to determine change. If your class agrees to these conditions a function can be marked skippable by the compose compiler.
Not if the data class is inside a module where the compose plugin isn't applied
a
Yes! I just read the library part.