-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chainable selectors #107
chainable selectors #107
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice improvement. Love seeing those tests.
I'm still fuzzy on requires. Wouldn't it make sense to have it in the top-level file and remove it from broadcaster? |
I'd vote to have the requires top-level in Maybe it also makes sense to switch to Zeitwerk in the future. |
I have moved all of the Generally speaking, I don't really understand what would motivate I don't want to merge until someone either concurs or gently informs me that I was a little too aggressive. |
This PR proposes 4 related enhancements that brings some recent changes in StimulusReflex full circle.
dom_id
function has been moved toCableReady::Identifiable
, which we will include in StimulusReflex'sreflex.rb
class as a way to consolidate one implementation of the function. Also, users can include this module in their own projects.selector
s can now acceptActiveRecord::Base
andActiveRecord::Relation
objects, the same way the new StimulusReflexmorph
method accepts them eg. implicit dom_id for morph selectors stimulus_reflex#436selector
as a first parameter. This is a shortcut since so many operations accept aselector
, and saves the developer from having to typeselector: "#users"
. If a selector is provided in theoptions
, it overrides a specified selector.selector
from the previous operation, if any. This means that you can specify a selector at the beginning of a chain, and it will automatically be picked up by succeeding operations until a new selector is used, at which point that becomes the "new previous" operation for all following operations; if a new selector is used, all previously used selectors are unmodifed.