A reactive component framework for TUIs, the Web, and more.
func Counter() Node {
count, setCount := Signal(0)
go func() {
for {
time.Sleep(time.Second / 30)
setCount(count() + 1)
}
}()
return P(Text("Count: "), BindText(count))
}- Pure Go | No extra compiler.
- Multi-plateform | Built-in support for TUIs and SPAs.
- Signal-based | Concurrency-safe reactive model with signals, effects, memos, etc.
- Components | Define your UI as declarative JSX-like components.
go mod init my-project
go get github.com/loom-go/loom github.com/loom-go/termpackage main
import (
"log"
"time"
"github.com/loom-go/loom"
. "github.com/loom-go/loom/components"
"github.com/loom-go/term"
. "github.com/loom-go/term/components"
)
func Counter() loom.Node {
frame, setFrame := Signal(0)
go func() {
for {
time.Sleep(time.Second / 120)
setFrame(frame() + 1)
}
}()
return Box(Text("Count: "), BindText(frame))
}
func main() {
app := term.NewApp()
for err := range app.Run(term.RenderInline, Counter) {
app.Close()
log.Fatalf("Error: %v\n", err)
}
}go run .And it's live!
You can visite loom's website for the full documentation.