Skip to content

loom-go/loom

Repository files navigation

「#」

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))
}

Features

  • 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.

Quick-start

go mod init my-project
go get github.com/loom-go/loom github.com/loom-go/term
package 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!

Documentation

You can visite loom's website for the full documentation.

License

MIT


Go Reference Go Report Card Codecov