From 807603512028dd78976fd9b20eb0e51a000595e8 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Thu, 11 Mar 2021 10:21:48 +0000 Subject: [PATCH] Clarify the difference between HTML and DynamicHTML (#389) Resolves #388. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 534421f7b..3138a1f9c 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,10 @@ struct SVGCircle: View { } ``` +`HTML` doesn't support event listeners, and is declared in the `TokamakStaticHTML` module, which `TokamakDOM` re-exports. The benefit of `HTML` is that you can use it for static rendering in libraries like [TokamakVapor](https://github.com/TokamakUI/TokamakVapor) and [TokamakPublish](https://github.com/TokamakUI/TokamakPublish). + +Another option is the `DynamicHTML` view provided by the `TokamakDOM` module, which has a `listeners` property with a corresponding initializer parameter. You can pass closures that can handle `onclick`, `onmouseover` and other DOM events for you in the `listeners` dictionary. Check out [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers) for the full list. + ### Arbitrary styles and scripts While [`JavaScriptKit`](https://github.com/swiftwasm/JavaScriptKit) is a great option for occasional interactions with JavaScript,