Sheroz Nazhmudinov
04/04/2020, 6:49 PMstate {…}
? Is it smth that’s used to control the state of the UI? If possible with an example, pls.
AFAIK, the source of truth for the UI should be a model class (Model annotated class). Correct me if I’m wrong here.Adam Powell
04/04/2020, 7:02 PMremember { mutableStateOf(...) }
mutableStateOf<T>(initialValue)
returns a MutableState<T>
, which also implements the read-only interface State<T>
. The returned implementation is backed by the same @Model
infrastructure, so changing its .value
property has the same effect as changing a property of a @Model
classvar myState by state { 0 }
and simply reference myState
as an Int
var that will be observed by the composition when it changesSheroz Nazhmudinov
04/04/2020, 7:08 PMAdam Powell
04/04/2020, 7:11 PMMutableState<T>
would be one of the first things you'd write to avoid having to do that all over, so it's built-in 🙂Sheroz Nazhmudinov
04/04/2020, 7:12 PMAdam Powell
04/04/2020, 7:15 PM