An open API service indexing awesome lists of open source software.

https://github.com/loom-go/loom

The reactive framework for Go.
https://github.com/loom-go/loom

Last synced: 23 days ago
JSON representation

The reactive framework for Go.

Awesome Lists containing this project

README

          

「#」

A reactive component framework for TUIs, the Web, and more.

```go
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](https://github.com/loom-go/loom/tree/main/signals/README.md) with signals, effects, memos, etc.
- **Components** | Define your UI as declarative JSX-like components.

## Quick-start

```bash
go mod init my-project
go get github.com/loom-go/loom github.com/loom-go/term
```

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

```bash
go run .
```

And it's live!

## Documentation

You can visite [loom's website](https://loomui.dev) for the full documentation.

## License

[MIT](./LICENSE)

---

[![Go Reference](https://pkg.go.dev/badge/github.com/loom-go/loom.svg)](https://pkg.go.dev/github.com/loom-go/loom)
[![Go Report Card](https://goreportcard.com/badge/github.com/loom-go/loom)](https://goreportcard.com/report/github.com/loom-go/loom)
[![Codecov](https://codecov.io/gh/loom-go/loom/graph/badge.svg?token=16KVY029LZ)](https://codecov.io/gh/loom-go/loom)