You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 11, 2025. It is now read-only.
David Ortinau edited this page Aug 27, 2019
·
1 revision
State in Comet is managed with the Model-View-Update pattern. A model state object is the source of truth. As anything updates the state of your view, Comet reacts by re-evaluating the View and Updating only what has changed.
This differs from traditional MVVM with data binding in that data only flows 1 direction, from the state object to the view.
Let’s look at a simple example right from our template code:
public class CounterView : View
{
readonly State<int> count = 0;
[Body]
View body() => new VStack(){
new Text(()=>$”You have tapped {count.value} times.”),
new Button(“Increment”, ()=>count.value++)
};
}
The change to state in the Button action triggers the Body to re-evaluate. Because the Comet UI is not on the native UI thread, this is fast!