When declaring an interface, I’ve kinda automatically defaulted to not exposing fields, but exposing functions directly, but not quite sure why.
I’ve now had this one case where I had an interface expose a
StateFlow<Foo>
and had it behind a function
stateFlow(): StateFlow<Foo>
but the implementation simply had the private declaration and the overridden function was simply doing
return this.stateFlow
.
So I wonder, is it weird for the interface to simply expose
val stateFlow: StateFlow<Foo>
instead? Are there any reasons why I would want to avoid that?