Created
February 9, 2022 21:16
-
-
Save Clancey/0d9bf071e7888382a351a65bf9374349 to your computer and use it in GitHub Desktop.
Comet with pure MVU, without any state.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RideTheComet : View | |
{ | |
public record CometRide | |
{ | |
public int Rides { get; init; } = 0; | |
public string CometTrain => "☄️".Repeat(Rides); | |
} | |
CometRide state = new CometRide(); | |
[Body] | |
View body() => new VStack { | |
new Text(()=> $"({state.Rides}) rides taken:{state.CometTrain}"), | |
new Button("Ride the Comet! ☄️", () => { | |
state = state with {Rides = state.Rides + 1}; | |
this.Reload(); | |
}) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment