make fn optional in app.Run
This commit is contained in:
parent
34e396271d
commit
a3791b599b
4 changed files with 36 additions and 4 deletions
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
func main() {
|
||||
// create the webview instance
|
||||
app := tiramisu.New(tiramisu.Options{
|
||||
app := tiramisu.New(tiramisu.TiramisuOptions{
|
||||
Title: "Tiramisu Example",
|
||||
Width: 800,
|
||||
Height: 600,
|
||||
|
|
6
examples/minimal/index.html
Normal file
6
examples/minimal/index.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h1>hello tiramisu!</h1>
|
||||
</body>
|
||||
</html>
|
24
examples/minimal/main.go
Normal file
24
examples/minimal/main.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
t "git.iwakura.rip/grng/tiramisu"
|
||||
webview "github.com/webview/webview_go"
|
||||
)
|
||||
|
||||
//go:embed index.html
|
||||
var html string
|
||||
|
||||
func main() {
|
||||
app := t.New(t.TiramisuOptions{
|
||||
Debug: true,
|
||||
Width: 800,
|
||||
Height: 600,
|
||||
Title: "Tiramisu",
|
||||
Hints: webview.HintFixed,
|
||||
})
|
||||
|
||||
app.HTML(html)
|
||||
app.Run()
|
||||
}
|
|
@ -40,15 +40,17 @@ func New(o TiramisuOptions) *Tiramisu {
|
|||
return t
|
||||
}
|
||||
|
||||
func (t *Tiramisu) Run(fn func()) {
|
||||
func (t *Tiramisu) Run(fns ...func()) {
|
||||
defer t.w.Destroy()
|
||||
t.w.Dispatch(func() {
|
||||
t.loadJSRuntime()
|
||||
t.loadGoRuntime()
|
||||
|
||||
for _, fn := range fns {
|
||||
if fn != nil {
|
||||
fn()
|
||||
}
|
||||
}
|
||||
})
|
||||
t.w.Run()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue