Skip to content

Commit

Permalink
Refactor code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewarrow committed Feb 16, 2024
1 parent 5e11563 commit 2ee85c4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions wasm/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func (g *Global) WasmReady(this js.Value, p []js.Value) any {
return nil
}

func (g *Global) Event(id string, fn func()) {
button := g.Document.ById(id)
thefunc := func(js.Value, []js.Value) any {
fn()
return nil
}
button.Set("onclick", js.FuncOf(thefunc))
}
func (g *Global) Click(id string, fn func(js.Value, []js.Value) any) {
button := g.Document.ById(id)
button.Set("onclick", js.FuncOf(fn))
Expand Down

0 comments on commit 2ee85c4

Please sign in to comment.