livefir / fir Goto Github PK
View Code? Open in Web Editor NEWBuild reactive html apps in Go
Home Page: https://livefir.fly.dev/
License: MIT License
Build reactive html apps in Go
Home Page: https://livefir.fly.dev/
License: MIT License
using https://github.com/livefir/fir/releases/tag/v0.3.5
cli new test01
cd test01
go mod init main
go mod tidy
go build .
/Users/apple/go/pkg/mod/github.com/livefir/[email protected]/markdown.go:332:44: undefined: extension.CJK
We want to send a diff of the changed template instead of everything. This is similar to how phoenix liveview works: https://www.poeticoding.com/how-phoenix-liveview-works/
For the following example html page:
<div
@fir:create:ok::todo="$fir.appendEl()"
@fir:query:ok::todos="$fir.replace()">
{{ block "todos" }}
<div>List of todos</div>
<div>Number of todos: {{ len .todos }}</div>
<ul>
{{ range .todos }}
{{ block "todo" . }}
<li>{{ .Text }}</li>
{{ end }}
{{ end }}
</ul>
{{ end }}
</div>
OnLoad:
Include the static parts in the rendered html page when the page is first loaded:
<script>
{
"todos": {
"d": [
"template@todo",
"{{ len .todos }}"
],
"s": [
"<div>List of todos</div>\n<ul>",
"</ul>\n<div>Number of todos: ",
"</div>"
]
},
"todo": {
"d": [
"{{.Text}}"
],
"s": [
"<li>",
"</li>"
]
}
}</script>
Respond with dynamic parts to an event:
OnEvent('create',...)
{
"type": "@fir:create:ok::todo",
"detail": {
"diff": [
"todo 1"
]
},
"target": ".fir-create-ok--todo"
}
OnEvent('query',...)
{
"type": "@fir:query:ok::todos",
"detail": {
"diff": {
"0": {
"d": [
[
"todo 1"
],
[
"todo 2"
]
]
}
}
},
"target": "fir-query-ok--todos"
}
The fir alpinejs plugin combines the static and dynamic parts to update the block/template in the browser.
Listen to alpinejs events generated on fir.emit or fir.submit to show response status(loading, error) to users.
I use nats with htmx.
fir could too .
then all endpoints are virtualised and so are the handlers.
cli gen html --model Todo todos text:string
cli gen html --entgo ./schema/Todo.go
Opens the door for alternative javascript clients
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.