Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Sep 25, 2023
1 parent 6de656e commit f9596df
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions examples/bind/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package main

import webview "github.com/webview/webview_go"

const html = `<html style="background: #1B2845; color: #eee;">
<button onclick="increment();">Tap me</button>
const html = `<button id="increment">Tap me</button>
<div>You tapped <span id="count">0</span> time(s).</div>
<script>
const counter = document.getElementById("count")
async function increment() {
const result = await window.Increment()
counter.textContent = result.count;
}
</script>
</html>`
const incrementBtn = document.getElementById("increment");
const counter = document.getElementById("count");
incrementBtn.addEventListener("click", async () => {
const result = await window.increment();
counter.textContent = result.count;
});
</script>`

type IncrementResult struct {
Count uint `json:"count"`
Expand All @@ -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}
})
Expand Down

0 comments on commit f9596df

Please sign in to comment.