D3vugu-components/main_wasm.go
2023-05-08 20:43:07 +02:00

46 lines
847 B
Go

//go:build wasm
package main
import (
"fmt"
"flag"
"github.com/vugu/vugu"
"github.com/vugu/vugu/domrender"
)
func main() {
mountPoint := flag.String("mount-point", "#vugu_mount_point", "The query selector for the mount point for the root component, if it is not a full HTML component")
flag.Parse()
fmt.Printf("Entering main(), -mount-point=%q\n", *mountPoint)
defer fmt.Printf("Exiting main()\n")
renderer, err := domrender.New(*mountPoint)
if err != nil {
panic(err)
}
defer renderer.Release()
buildEnv, err := vugu.NewBuildEnv(renderer.EventEnv())
if err != nil {
panic(err)
}
rootBuilder := vuguSetup(buildEnv, renderer.EventEnv())
for ok := true; ok; ok = renderer.EventWait() {
buildResults := buildEnv.RunBuild(rootBuilder)
err = renderer.Render(buildResults)
if err != nil {
panic(err)
}
}
}