Skip to content

Instantly share code, notes, and snippets.

@Clancey
Created February 9, 2022 21:14
Show Gist options
  • Save Clancey/73ad82df48165c89c2f2dbc0f84379e2 to your computer and use it in GitHub Desktop.
Save Clancey/73ad82df48165c89c2f2dbc0f84379e2 to your computer and use it in GitHub Desktop.
Comet without any INPC/Bindings
public class RideTheComet : View
{
public record CometRide
{
public int Rides { get; init; } = 0;
public string CometTrain => "☄️".Repeat(Rides);
}
State<CometRide> state = new CometRide();
[Body]
View body() => new VStack {
new Text(()=> $"({state.Value.Rides}) rides taken:{state.Value.CometTrain}"),
new Button("Ride the Comet! ☄️", () => state.Value = state.Value with {Rides = state.Value.Rides + 1})
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment