3 Commits

Author SHA1 Message Date
4c022b13ac Remove accidentally committed binary
All checks were successful
CI / build (pull_request) Successful in 29s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 17:19:04 +01:00
a580df7b72 Add decrement button to counter example
All checks were successful
CI / build (pull_request) Successful in 29s
Address review feedback to include a decrement button that
demonstrates reactive updates in both directions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 17:18:49 +01:00
0f924d8e8a Add counter example demonstrating signals
All checks were successful
CI / build (pull_request) Successful in 28s
Basic example showing:
- Creating a signal with NewSignal
- Reading value with Get()
- Writing value with Set()
- Button click handler
- Reactive text that updates when signal changes

Closes #4

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:59:54 +01:00

36
examples/counter/main.go Normal file
View File

@@ -0,0 +1,36 @@
//go:build js && wasm
package main
import (
"fmt"
"git.flowmade.one/flowmade-one/iris/reactive"
"git.flowmade.one/flowmade-one/iris/ui"
)
func main() {
// Create a signal with initial value 0
count := reactive.NewSignal(0)
view := ui.NewView()
// Reactive text that updates when count changes
view.Child(ui.TextFromFunction(func() string {
return fmt.Sprintf("Count: %d", count.Get())
}))
// Button that increments the count on click
view.Child(ui.Button(func() {
count.Set(count.Get() + 1)
}, ui.TextFromString("Increment")))
// Button that decrements the count on click
view.Child(ui.Button(func() {
count.Set(count.Get() - 1)
}, ui.TextFromString("Decrement")))
ui.NewApp(view)
select {}
}