# 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
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
package main
import (
"time"
"github.com/Instantan/magic"
)
var homeView = magic.View(`
<!DOCTYPE html>
<html>
<head>
<title>Time</title>
</head>
<body>
<p>{{counter}}</p>
</body>
</html>
`)
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
# Packages
No description provided by the author
# Functions
Calls the animate(keyframes, options) function for the given ids (if no id is given it uses the id of the socket).
Assign assigns a new value to the given socket.
Calls the blur() function for the given ids (if no id is given it uses the id of the socket).
Calls the click() function for the given ids (if no id is given it uses the id of the socket).
Leaves the fullscreen mode of the window.
No description provided by the author
No description provided by the author
Compresses the given http.Handler with gzip.
No description provided by the author
Disconnects the socket from the client side.
Calls the focus() function for the given ids (if no id is given it uses the id of the socket).
Call this function as the first function in your code.
Must panics if the passed error is not nil.
Sends a navigation event to the given socket, the navigate is a live navigation.
No description provided by the author
No description provided by the author
Enters the fullscreen mode of the window.
RefreshFile reloads a img, script, favicon or source element (every element with a "src" attribute).
Sends the reload event to the given socket, the reload is not a full reload, instead its a websocket reconnect.
Calls the reset() function for the given ids (if no id is given it uses the id of the socket).
Calls the scrollIntoView(options) function for the given ids (if no id is given it uses the id of the socket).
No description provided by the author
UpdateURL changes the clients url to the request url without navigating.
Use is a way to add a hook that listens to an unmount event.
UseLiveRoutine spawns a new goroutine when the connection is live.
UseRoutine spawns a new goroutine that gets closed when it receives the unmount event.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author