While this was primarily a bug-fix release, there were some exciting leaps forward, especially on the CableReady side. You should check out the new graft operation, which seems dry until you realize that you can move elements on your DOM without losing the internal state of your Stimulus controllers.
CableReady v4.5.0 has eight new operations:
cable_ready method now works with custom operations
responsibility for a Reflex has been moved to the element holding the controller
life-cycle callbacks now return the correct element reference
fixed an issue with form data serialization for characters like
dom_id which now correctly prefixes with a
addressed issue with
morphdom which interfered with input/select elements losing their value
For those of you who were tired of getting endless warnings about missing controllers when deleting elements via a Reflex, we're thrilled with the way Reflex controller responsibility is now managed.
Developer happiness is not a catch-phrase. We are actively working to improve the quality of life for the more than 13,000 people downloading StimulusReflex every week, because happy developers enjoy a great surplus.
As with all major StimulusReflex releases, v3.4 is packed full of new features from 52 contributors that are directly inspired by the questions, requests and grievances of the 1000+ people on the SR Discord:
we completely overhauled the client-side Reflex logging with per-Morph granularity
a brand new and shockingly customizable server-side Reflex colorized logging module
finalize life-cycle stage that occurs after all DOM mutations are complete
support for lazily evaluated signed and unsigned Global ID to model instances
cable_ready method that automatically broadcasts to the current user
speaking of CableReady, the new v4.4 means operation and broadcast method chaining as well as customizable should/did morph callbacks
an optional (but recommended) "tab isolation" mode to restrict Reflexes to the current tab
major improvements behind the scenes to better handle (many) concurrent Reflex actions
render is now automatically delegated to the current page's controller
StimulusReflex library configuration courtesy of our new initializer system
opt-in Rack middleware support for Page Morphs
automatic support for mirroring DOM events with jQuery events, if jQuery is present
drop-in Stimulus 2 support
warnings to alert you if your caching is off or your gem+npm versions don't match
JS bundle size drops from 43kb to 11.4kb - including CableReady, morphdom and ActionCable
More than anything, StimulusReflex v3.4 feels fast and incredibly solid. We didn't take any shortcuts when it came to killing bugs and doing things right. We owe that to our users as we use our surplus to build the world we want to live in, together. 🌲
make sure that you update
stimulus_reflex in both your Gemfile and package.json
it's very important to remove any
include CableReady::Broadcaster statements from your Reflex classes
OPTIONAL: enable isolation mode by adding
isolate: true to the initialize options
OPTIONAL: generate an initializer with
rails g stimulus_reflex:config
bundle remove cable_ready && yarn remove cable_ready
Introduces the concept of Morphs to StimulusReflex.
Page Morphs provide a full-page morphdom refresh with controller processing as an intelligent default.
Selector Morphs allow you to intelligently update target elements in your DOM, provided by regenerated partials or ViewComponents.
Nothing Morphs provide a lightning-fast RPC mechanism to launch ActiveJobs, initiate CableReady broadcasts, call APIs and emit signals to external processes.
There's a handy chart showing how the different Morphs work. Find all of the documentation and examples behind the link below.