rails generate channel test
in your Rails project folder. This will ensure that your ActionCable setup has been initialized, although you should verify that in your app/javascript/packs/application.js
you have import 'channels'
present.ActionCable is connected
in your browser's Console Inspector and Client is live
in your server's STDOUT log stream.app/javascript/channels/consumer.js
where it is so that you can pass it to StimulusReflex.initialize()
and share one ActionCable connection.app/javascript/packs/application.js
pack file:debug: true
to the initialize options like this:↑ stimulus ↑
) shows the target "Pagy#paginate" (name of the Reflex class and the Reflex action being called) as well as an object containing the reflexId, any args
(arguments) being passed to stimulate()
, the Stimulus controller
that invoked the Reflex, and the element
that the Stimulus controller instance was placed on.pagy
Stimulus controller on it, matching the name of the Reflex class, Pagy
. This means any callbacks defined in the pagy
Stimulus controller will be called.pagy
Stimulus controller on it, the controller would be the default controller for all Reflexes, stimulus-reflex
. If you inspect your DOM, you'll see that all elements with a data-reflex
attribute have gained a data-controller="stimulus-reflex"
. Knowing is half the battle!↓ reflex ↓
and their job is to report on exactly how things went down.morph
operations are always used for Page Morphs.data-reflex-root
attribute is used to specify one or more CSS selectors, as seen in the example above.morph
operation. They tend to be extremely fast because they do not need to go through the ActionDispatch controller stack. There could be a blend of morph
and inner_html
CableReady operations in one Reflex.CLONED
instead of showing a duration, because non-active tabs have no way of knowing when the Reflex was started.warn
log level, as is common in development environments:session_id
- the first 8 characters of the current user's session idsession_id_full
- the current user's session idreflex_info
- the Reflex Class # the Reflex actionoperation
- the CableReady operation used to execute the current Morphreflex_id_full
- the unique UUIDv4 identifying the Reflexmode
- whether the current Morph is Page, Selector or Nothingselector
- the destination CSS selector for the content to be updatedoperation_counter
- shows the current and total Morph count for this Reflexconnection_id
- the first 8 characters of the ActionCable Connection identifierconnection_id_full
- the ActionCable Connection identifieremail
attribute, you could include the current user's email in your new log string:identified_by
resources defined, the logger will look into each one of them in the order they are defined, looking for the first match.sleep
in your Controller Action to "slow down" a CableReady broadcast. Not only will this not work - the same problem will happen, slower - but freezing the Ruby thread means the application server has fewer resources to respond to other requests.sleep
in a primary execution thread. Chances are, you should use an ActiveJob with a delayed start.beforeReflex
client-side callback that wants to re-parent an element. Perhaps you use CableReady#remove
to destroy the element that holds the stimulus-reflex
controller element which initiated the Reflex.stimulus-reflex
controller in the same position in your DOM hierarchy so that it can finish the transaction.finalizeReflex
callback to perform any desired DOM manipulations client-side after the Reflex has fully completed running all operations.push_state
method allows you to drive the page the user sees from your server-side code.dispatch_event
method to send an instruction to a Stimulus controller. Upon receving your event, you can easily initiate a Turbo Drive visit, call History.pushState directly or just change the window.location
if that's all you need.connect
method, jQuery's load
event, a Turbo Drive visit event or your own pageshow event handler, we recommend that you don't attempt to immediate call a Reflex operation as soon as the page loads. This advice is especially important in the context of Page Morphs.Application.start()
data-avenger
attributes instead of data-reflex
attributes. 🦸morph
method.data-reflex-permanent
will not work.div
into a span
. morphdom just doesn't care.data-reflex-permanent
get morphed. We're aware of it, and we've tried to fix it.index.js
in your app/javascript/controllers
that you should import into your application pack.unless: -> { @stimulus_reflex }
rails dev:cache
one time.data-reflex="Foo#action"
on an element does not automatically attach an instance of the foo
Stimulus controller (if indeed one exists).foo
or any other Stimulus controllers on your elements, you have to attach them yourself.beforeReflex
callback.data-reflex-permanent
attribute and an id
attribute until we figure out what's up.action_cable_meta_tag
in your HEAD
.CableReady::Broadcaster
, which is already avalable in scope.redirect_to
in a Page Morph. If you try to return an HTTP 302 in your controller during a Reflex action, your page content will become "You are being redirected."stimulus_reflex
npm package version is identical to your Ruby gem version.config/cable.yml
set up properly? You must install Redis as the adapter in development mode.ActionController::RoutingError Exception: No route matches
errors getting you down? You might need to add Rack middleware to your initializer.ApplicationController.render
to regenerate partials that make use of view helpers? Are those helpers generating URL routes that point to example.com
? You can fix this by setting up your default_url_options.(WARNING: Can't locate the stimulus_reflex npm package)
when you deploy to Heroku? Try updating to the most recent Cedar stack version. This appears to be fixed as of Cedar-20.data-reflex-permanent
isn't being respected, try adding a unique id
parameter as well. Note that if your Morphs are being performed with inner_html
operations and you need data-reflex-permanent
to work, you will have to reconfigure your Morph to work with morphdom
(see the Morphing Sanity Checklist)DISABLE_SPRING=1
environment variable and restarting your server.pkill -f spring
bin/spring binstub --remove --all
bin/rails
which says: load File.expandpath("spring", _dir)