From f5dbc2de9ffd5b746c90df284d32e938ffcd8be3 Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Fri, 20 Jan 2023 11:11:27 +0100 Subject: [PATCH] Update demo projects --- elixirkit/demo/rel/appkit/Sources/Demo/Demo.swift | 9 +++++++++ elixirkit/demo/rel/winforms/Demo.cs | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/elixirkit/demo/rel/appkit/Sources/Demo/Demo.swift b/elixirkit/demo/rel/appkit/Sources/Demo/Demo.swift index dfc162411..ad16305f5 100644 --- a/elixirkit/demo/rel/appkit/Sources/Demo/Demo.swift +++ b/elixirkit/demo/rel/appkit/Sources/Demo/Demo.swift @@ -24,6 +24,15 @@ class AppDelegate: NSObject, NSApplicationDelegate { ElixirKit.API.publish("log", "Hello from AppKit!") + ElixirKit.API.addObserver(queue: .main) { (name, data) in + switch name { + case "log": + print("[client] " + data) + default: + fatalError("unknown event \(name)") + } + } + let menuItemOne = NSMenuItem() menuItemOne.submenu = NSMenu(title: "Demo") menuItemOne.submenu?.items = [ diff --git a/elixirkit/demo/rel/winforms/Demo.cs b/elixirkit/demo/rel/winforms/Demo.cs index 565e3e693..469bf445b 100644 --- a/elixirkit/demo/rel/winforms/Demo.cs +++ b/elixirkit/demo/rel/winforms/Demo.cs @@ -19,6 +19,19 @@ static class DemoMain ElixirKit.API.Publish("log", "Hello from Windows Forms!"); + ElixirKit.API.Subscribe((name, data) => + { + switch (name) + { + case "log": + Console.WriteLine($"[client] {data}"); + break; + + default: + throw new Exception($"unknown event {name}"); + } + }); + ApplicationConfiguration.Initialize(); Application.Run(new DemoForm()); }