Skip to content

Commit f9596df

Browse files
committed
Apply suggestions
1 parent 6de656e commit f9596df

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

examples/bind/main.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ package main
22

33
import webview "github.com/webview/webview_go"
44

5-
const html = `<html style="background: #1B2845; color: #eee;">
6-
<button onclick="increment();">Tap me</button>
5+
const html = `<button id="increment">Tap me</button>
76
<div>You tapped <span id="count">0</span> time(s).</div>
87
<script>
9-
const counter = document.getElementById("count")
10-
async function increment() {
11-
const result = await window.Increment()
12-
counter.textContent = result.count;
13-
}
14-
</script>
15-
</html>`
8+
const incrementBtn = document.getElementById("increment");
9+
const counter = document.getElementById("count");
10+
incrementBtn.addEventListener("click", async () => {
11+
const result = await window.increment();
12+
counter.textContent = result.count;
13+
});
14+
</script>`
1615

1716
type IncrementResult struct {
1817
Count uint `json:"count"`
@@ -26,7 +25,7 @@ func main() {
2625
w.SetSize(480, 320, webview.HintNone)
2726

2827
// A binding that increments a value and immediately returns the new value.
29-
w.Bind("Increment", func() IncrementResult {
28+
w.Bind("increment", func() IncrementResult {
3029
count++
3130
return IncrementResult{Count: count}
3231
})

0 commit comments

Comments
 (0)