This is part one of a two part series on Stimulus controller communication. The link to part two will be located here once it has been published.
From the time I’ve started playing around with Stimulus, I’ve been thinking about the best way that controllers can communicate with each other.
The nice thing about Stimulus is that the state of the controller is representable from within the DOM itself,
meaning that if a property
of a controller needs to change, it can be done so by simply modifying the attribute value of the element the controller is bound to
(see here for how that works).
This, however, doesn’t extend nicely to instances when you only need to notify the controller of an event or send a
message that is more one shot: “I did a thing”, or “please do that thing”. It’s not always possible to translate these interactions to
one that is based on modifying attribute values, and most attempts to do so always end up as a bit of a code smell.
After a bit of experimentation, I think I’ve found a method which works for me.
Read more →
One of the advantages of maintaining a blog is that it works as a good destination to record how to do something
that you find yourself needing to do occasionally, but keep forgetting how to do it.
Documenting the process in public, and in a way that will hopefully help someone else that needs to do
the same thing, is a laudable goal in itself, but it does raise the question on why one would do so
when there are many,
other blog posts on exactly the same topic. At least this way,
there is a reference that I know exists, and is written in a way that works for me, specifically because
I wrote it myself.
With this preamble out of the way, here is what you need to know in order to build a WASM project in Go,
and execute it in a browser.
Read more →
Over the last several months, I’ve been doing a bit of development
using Buffalo, which is a rapid web development framework in Go,
similar to Ruby on Rails. Like Ruby on Rails, the
front-end layer is very simple: server-side rendered HTML with a bit of jQuery augmenting
the otherwise static web-pages.
After a bit of time, I wanted to add a bit of dynamic flare to the frontend, like automatically
fetch and update elements on the page. These projects were more or less small
personal things that I didn’t want to spend a lot of time maintaining, so
doing something dramatic like rewriting the UI in React or Vue would have been overkill.
jQuery was available to me but using it always required a bit of boilerplate to setup the bindings
I since came across Stimulus, which looks to provide what I was looking for.
Read more →