I’m giving a talk on Stimulus to my local Ruby meetup in a couple of weeks. My company uses Stimulus and I have plenty of simple examples, but I’d love to hear what you think a beginner should know, especially if you had an “ah ha” moment.
I feel you should include all the simple examples that are used in your company. It will give them the taste of using stimulus in real world.
Example 1: stimulus example to replace jquery events
Example 2: stimulus example to replace jquery plugin
…
How to listen for global events, i.e @window
Your ideas of inter-controller communication, i.e. parent component - fetches data and calls methods from controller in targets.
I’m pretty new to Stimulus but the thing I noticed was the similarities with the syntax of ‘actions’ are like Rails’ routes, click=>controller#action
. Targets are kind of like params
too. That is how I’ve wrapped my head around things so far.
I think the biggest benefits are those who are looking to remove JQuery and start building their own small interactions like what @Kiran_Patil mentioned above. I would also highlight the ability to reuse controllers in many ways, you can start to really see the power in simplicity that way. I think the example in the docs is something like "<input type="text" data-action="focus->field#highlight">"
.