using Spry; using Inversion; /** * SimpleCounterDemo - A basic counter demo for the Actions documentation * * Demonstrates: * - spry-action for same-component actions * - spry-target for scoped targeting * - State management via a singleton store */ public class SimpleCounterDemo : Component { private CounterDemoStore store = inject(); public override string markup { get { return """
0
"""; }} public override async void prepare() throws Error { this["display"].text_content = store.count.to_string(); } public async override void handle_action(string action) throws Error { switch (action) { case "Increment": store.count++; break; case "Decrement": store.count--; break; } } } /** * CounterDemoStore - Singleton store to persist counter state */ public class CounterDemoStore : Object { public int count { get; set; default = 0; } }