https://kotlinlang.org logo
#compose
Title
# compose
m

manueldidonna

09/03/2020, 9:57 PM
How to mark external classes (imported from libraries or modules which don't depend on compose) as
Stable/Immutable
? I know that the public properties of that classes won't change
a

Adam Powell

09/03/2020, 11:32 PM
Unfortunately you can't yet, but we recognize the need to be able to maintain a side channel list of these that you can provide to compose
we're also looking at inferring these on some level, which should alleviate at least some cases where this is needed today
m

manueldidonna

09/04/2020, 12:00 AM
Is something like this possible or it would just be a hideous workaround?
Copy code
@Stable
typealias StableClass = Class
a

Adam Powell

09/04/2020, 12:01 AM
I don't think that works? @Leland Richardson [G] would know for sure though
l

Leland Richardson [G]

09/04/2020, 12:23 AM
it wouldn’t work, no
but we are working on a solution to handle this in a more general way to where you (ideally) don’t have to do this, and if you do, it will be possible in some way (bot probably not through a typealias like you’re proposing here)
❤️ 1
j

Jason Ostrander

09/04/2020, 1:32 PM
@Leland Richardson [G] Obviously this isn’t ideal, but would creating a simple wrapper object in the compose module allow this? Something like
Copy code
@Stable
data class Wrapper(val model: Model)
m

manueldidonna

09/04/2020, 2:02 PM
I used that workaround but reading the documentation of
StableMarker
I get confused because it's written that all the public properties of a stable class must be stable
2 Views