morph
for Page Morphs and some Selector Morphs, inner_html
for Selector Morphs that don't use morph
, and dispatch_event
for Nothing Morphs, as well as aborted/halted Reflexes and sending errors that occur in a Reflex action.inner_html
is that the content you send to replace your existing DOM elements has to match up. If you replace an element with something completely different, morph
just won't work. You can read all about this in the Morphing Sanity Checklist.CableReady::Broadcaster
is already included, giving you access to the dom_id
helper and a special version of the cable_ready
method. If you call cable_ready
in a Reflex action without specifying a stream or resource - in other words, no brackets - CableReady will piggyback on the StimulusReflex ActionCable channel.cable_ready[stream_name]
. stream_name
is the internal variable StimulusReflex uses to hold the stream identifier it uses to send updates to the current user.cable_ready
method is that broadcast
methods must appear at the end of a method chain. This is because calling cable_ready.broadcast
without queueing any additional operations already has a function when using CableReady; it tells CableReady to broadcast any enqueued operations on all string-based identifier channels.cable_ready
with a stream identifier in brackets.CableReady::Broadcaster
in your Reflex classes. It's already present in the Reflex scope and including it again will cause errors.morph
vs. a CableReady operationmorph
and inner_html
operations, you might be wondering when or if to just use CableReady operations directly instead of calling StimulusReflex's morph
.broadcast
.broadcast
edmorph
operationsbroadcast
edbroadcast
called on them well be immediately delivered to the client, while any CableReady operations queued in a Page or Selector Morph Reflex action that aren't broadcast by the end of the action will be broadcast along with the StimulusReflex-specific morph
operations. The StimulusReflex operations execute first, followed by any remaining CableReady operations.broadcast
.CableReady#push_state
. There are scenarios where you might want to update your page and then change the URL. If you attempt to change the URL of the page during the Reflex action, the StimulusReflex morph
updates will be unsuccessful due to the URL changing. StimulusReflex won't execute if the page has changed since the beginning of the Reflex.push_state
without actually calling broadcast
, this ensures that the Reflex page updates can occur before push_state
changes the URL.morph
method calls, especially to take advantage of functions not supported directly by StimulusReflex, such as CableReady's insert_adjacent_html
.morph
and CableReady operations, you might consider installing radiolabel. It's a powerful visual aid that allows you to see your CableReady operations happen.