Now Reading
Reactive html apps in Go & alpine.js

Reactive html apps in Go & alpine.js

2023-05-09 19:03:52

Later we use fir’s alpinejs plugin to reinforce the shape
submission and obtain the re-rendered template as an
occasion. The occasion is dealt with by the
$fir.exchange() helper perform which
updates the interior content material of the div on which the occasion
listener is asserted. Click on the buttons beneath to see
reactivity in motion.

As you may discover, the rely worth is up to date with out a
web page reload. The server aspect code stays unchanged.

Fir’s magic expression

@fir:event-name:event-state::template-name

piggybacks on
alpinejs event binding syntax
to declare
html/templates
to be re-rendered on the server.
fir's magic
                            expression

If the handler response for occasion
inc is okay then
re-render the template named
rely on the server and return the
html output to the occasion listener as a

CustomEvent
. The
CustomEvent.detail
property is utilized by the alpinejs plugin helper
$fir.exchange() to replace the div
on which the listener is asserted.

Go the the listing the place you may have these information and run:

See Also

go run counter.go

Open your browser and go to
http://localhost:9867
to see the reactive counter in motion.

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top