# compose


05/25/2022, 6:27 AM
Can I mark this interface as
? The interface is defined like this:
Copy code
interface SomeState {
  val propertyA: NonStableTypeA
  val propertyB: NonStableTypeB
And in the implementation class, all public properties are backed by
Copy code
internal class SomeStateImpl: SomeState {
  override var propertyA: NonStableTypeA by mutableStateOf(...)
    internal set
  override var propertyB: NonStableTypeB by mutableStateOf(...)
    internal set
👍 1


05/25/2022, 8:55 AM
yes, you can


05/25/2022, 9:21 AM
Why? According to the document:
```* When applied to a class or an interface, [Stable] indicates that the following must be true:
* 1) The result of [equals] will always return the same result for the same two instances.
* 2) When a public property of the type changes, composition will be notified.
* 3) All public property types are stable.```
Since some of its public property types are unstable, so the interface itself is also unstable.
The implementation class
is stable. But since it also implements another interface for internal usage, I don’t want to expose it directly.
Is exposing the implementation class directly the only way to communicate the stability information to the compiler?

Albert Chang

05/25/2022, 10:26 AM
The “public property types” here refers to the types of the backing fields, which in your case are `MutableState`s. Stability can’t be inferred solely from the interface definition but if you know that its implementations are stable, you can mark it stable.
👀 2
☝🏼 1
☝🏻 1
Copy code
fun SomeFun(state: SomeState)
If you have a composable like this, actually the stabilities of `SomeState`’s implementations are irrelevant here. The metrics of the function will solely depend on the stability of the interface itself.
today i learned 1

Zach Klippenstein (he/him) [MOD]

05/25/2022, 3:06 PM
on an interface isn't just a contract for consumers, it's also a contract to all implementers is they must also ensure they are stable.
👍 1
👍🏻 1