Compare commits
1 Commits
issue-1-re
...
issue-2-he
| Author | SHA1 | Date | |
|---|---|---|---|
|
5aa1498ab7
|
32
examples/hello/main.go
Normal file
32
examples/hello/main.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
//go:build js && wasm
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.flowmade.one/flowmade-one/iris/reactive"
|
||||||
|
"git.flowmade.one/flowmade-one/iris/ui"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
count := reactive.NewSignal(0)
|
||||||
|
|
||||||
|
// Increment count every second to show reactivity
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
count.Set(count.Get() + 1)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
view := ui.NewView()
|
||||||
|
view.Child(ui.TextFromFunction(func() string {
|
||||||
|
return fmt.Sprintf("Hello, Iris! Count: %d", count.Get())
|
||||||
|
}))
|
||||||
|
|
||||||
|
ui.NewApp(view)
|
||||||
|
|
||||||
|
select {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user