https://github.com/instantan/magic
Transform your web development with a touch of Magic
https://github.com/instantan/magic
liveview
Last synced: over 1 year ago
JSON representation
Transform your web development with a touch of Magic
- Host: GitHub
- URL: https://github.com/instantan/magic
- Owner: Instantan
- Created: 2023-03-13T15:57:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-12T21:08:12.000Z (almost 3 years ago)
- Last Synced: 2025-01-22T21:16:00.388Z (over 1 year ago)
- Topics: liveview
- Language: Go
- Homepage: https://magic.instantan.io
- Size: 1.13 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# magic

Magic is a Golang web framework that simplifies web development.
With under 12kb JavaScript, it's powerful yet easy to use for building
efficient web applications.
# Getting started
For a simple live counter example:
> main.go
```go
package main
func main() {
mux := http.NewServeMux()
mux.Handle("/", magic.ComponentHTTPHandler(home))
log.Print("Listening to http://localhost:8070")
if err := http.ListenAndServe(":8070", mux); err != nil {
log.Fatal(err)
}
}
```
> home.go
```go
package main
import (
"time"
"github.com/Instantan/magic"
)
var homeView = magic.View(`
Time
{{time}}
`)
var home = magic.Component(func(s magic.Socket, e magic.Empty) magic.AppliedView {
magic.UseLiveRoutine(s, func(quit <-chan struct{}) {
t := time.NewTicker(time.Millisecond * 1000)
for {
select {
case c := <-t.C:
magic.Assign(s, "time", c.String())
case <-quit:
t.Stop()
return
}
}
})
return homeView(s)
})
```
# Roadmap
- Implement temporal data patches
- Clean up socket.go, ref.go and view.go
- Benchmarking, memory reduction and performance improvements
- Unit tests