Skip to content

Go backend library for the Phoenix LiveView JS client. Enables rich, real-time user experiences with server-rendered HTML.

Notifications You must be signed in to change notification settings

sethpollack/go-live-view

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go LiveView

Go backend library for the Phoenix LiveView JS client. Enables rich, real-time user experiences with server-rendered HTML.

This is still very much a work in progress. The API is not stable and is subject to change.

Basic Example:

type Live struct {
	Count int
}

func (l *Live) Event(s lv.Socket, event string, _ params.Params) error {
	if event == "inc" {
		l.Count++
	}

	if event == "dec" {
		l.Count--
	}

	return nil
}

func (l *Live) Render(_ rend.Node) (rend.Node, error) {
	return html.Div(
		html.H1(
			std.Text(&l.Count), // use pointer for dynamic values to optimize diffs to the client.
		),
		html.Button(
			std.Text("inc"),
			html.Attr("phx-click", "inc"),
		),
		html.Button(
			std.Text("dec"),
			html.Attr("phx-click", "dec"),
		),
	), nil
}

See the examples directory for full examples.

About

Go backend library for the Phoenix LiveView JS client. Enables rich, real-time user experiences with server-rendered HTML.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages