morphfor Page Morphs and some Selector Morphs,
inner_htmlfor Selector Morphs that don't use
dispatch_eventfor Nothing Morphs, as well as aborted/halted Reflexes and sending errors that occur in a Reflex action.
inner_htmlis that the content you send to replace your existing DOM elements has to match up. If you replace an element with something completely different,
morphjust won't work. You can read all about this in the Morphing Sanity Checklist.
CableReady::Broadcasteris already included, giving you access to the
dom_idhelper and a special version of the
cable_readymethod. If you call
cable_readyin a Reflex action without specifying a stream or resource - in other words, no brackets - CableReady will piggyback on the StimulusReflex ActionCable channel.
stream_nameis the internal variable StimulusReflex uses to hold the stream identifier it uses to send updates to the current user.
cable_readymethod is that
broadcastmethods must appear at the end of a method chain. This is because calling
cable_ready.broadcastwithout 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_readywith a stream identifier in brackets.
morphvs. a CableReady operation
inner_htmloperations, you might be wondering when or if to just use CableReady operations directly instead of calling StimulusReflex's
broadcastcalled 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
morphoperations. The StimulusReflex operations execute first, followed by any remaining CableReady operations.
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
morphupdates will be unsuccessful due to the URL changing. StimulusReflex won't execute if the page has changed since the beginning of the Reflex.
push_statewithout actually calling
broadcast, this ensures that the Reflex page updates can occur before
push_statechanges the URL.
morphmethod calls, especially to take advantage of functions not supported directly by StimulusReflex, such as CableReady's
morphand CableReady operations, you might consider installing radiolabel. It's a powerful visual aid that allows you to see your CableReady operations happen.