From ba0307eb2780c45fad38498af267d4206b5709b1 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Fri, 22 Sep 2023 19:16:58 +0200 Subject: [PATCH] Apply suggestions --- examples/bind/main.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/bind/main.go b/examples/bind/main.go index b70e66b..9a301ba 100644 --- a/examples/bind/main.go +++ b/examples/bind/main.go @@ -2,17 +2,16 @@ package main import webview "github.com/webview/webview_go" -const html = ` - +const html = `
You tapped 0 time(s).
-` + const incrementBtn = document.getElementById("increment"); + const counter = document.getElementById("count"); + incrementBtn.addEventListener("click", async () => { + const result = await window.increment() + counter.textContent = result.count; + }); +` type IncrementResult struct { Count uint `json:"count"` @@ -26,7 +25,7 @@ func main() { w.SetSize(480, 320, webview.HintNone) // A binding that increments a value and immediately returns the new value. - w.Bind("Increment", func() IncrementResult { + w.Bind("increment", func() IncrementResult { count++ return IncrementResult{Count: count} })