Hotwire Summer: Self-destructing StimulusJS controllers
Add sprinkles of Javascript behavior with Stimulus controllers that run a few lines of code and then remove themselves from the page. Like inlined jQuery snippets but for the modern times!
Sometimes you need a little sprinkle of JavaScript to make a tiny UX improvement.
In the olden days, full-stack developers would often drop small jQuery snippets straight into the page:
<script type="application/javascript">
$(".flash-container").delay(5000).fadeOut()
$(".items").last().highlight()
</script>
It got the job done, but it wasn't the best.
In Hotwire apps you can use a "self-destructing" Stimulus controller to achieve the same result.
In this article I show three examples of this pattern from my production codebase.
👉 Read it here: Self-destructing StimulusJS controllers
📣 Have feedback? Join the discussion on Twitter
Stay boring!
- Matt
Can it be achieved using Alpine.js ?