diff --git a/Ooui/UI.cs b/Ooui/UI.cs index 25089f6..8fd2718 100644 --- a/Ooui/UI.cs +++ b/Ooui/UI.cs @@ -8,6 +8,10 @@ namespace Ooui { } + public static void Publish (string path, Func ctor) + { + } + public static Element GetElementAtPath (string path) { throw new System.Collections.Generic.KeyNotFoundException ($"{path} does not exist"); diff --git a/Samples/ButtonSample.cs b/Samples/ButtonSample.cs new file mode 100644 index 0000000..182d4f5 --- /dev/null +++ b/Samples/ButtonSample.cs @@ -0,0 +1,29 @@ +using System; +using Ooui; + +namespace Samples +{ + public class ButtonSample + { + Button MakeButton () + { + var button = new Button ($"Click me!"); + var count = 0; + button.Clicked += (s, e) => { + count++; + button.Text = $"Clicked {count} times"; + }; + return button; + } + + public void Publish () + { + var b = MakeButton (); + + UI.Publish ("/shared-button", b); + UI.Publish ("/button", MakeButton); + } + } +} + + diff --git a/Samples/Program.cs b/Samples/Program.cs index 0e3ee33..28a4ce7 100644 --- a/Samples/Program.cs +++ b/Samples/Program.cs @@ -8,14 +8,11 @@ namespace Samples static int Main (string[] args) { var server = new Server (); - var button = new Button() { - Title = "The best button", - Name = "TestButton", - Value = "Click Me", - Text = "I am a button, click me!" - }; - server.Publish ("/button", button); - server.RunAsync ("http://*:8080/").Wait (); + server.RunAsync ("http://*:8080/"); + + new ButtonSample ().Publish (); + + Console.ReadLine (); return 0; } }