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

Klaas Kabini

02/01/2020, 5:07 PM
Does
@Stable
annotation on the composable functions within the framework mean the composable functions are stable and not subject to change? Is that right ?
👍 1
a

Adam Powell

02/01/2020, 5:11 PM
@Stable
appears on types rather than on functions, and usually on interfaces rather than concrete types. At a first approximation you can think of it as saying, "this object is either
@Model
or
@Immutable
."
The contract is, if
.equals
would return
true
for this object, composition involving it can be skipped. If an object instance itself changes, it will notify the Compose runtime as appropriate.
since
foo.equals(foo)
is always true, that last part of the contract is important so that compose doesn't skip over important changes that need to be reflected.
@Model
automatically meets this contract, and
@Immutable
does as well by declaring that an object won't change at all.
k

Klaas Kabini

02/01/2020, 5:19 PM
Thanks for the explanation. Now I know. At first glance I thought it mean't stable api🤣🤣
a

Adam Powell

02/01/2020, 5:20 PM
🙂 that's good feedback too, thanks!
5 Views