⚡️ Hotwire dev newsletter - May 2022 edition
A curated, monthly roundup of the best Turbo (Native), Stimulus, and Strada articles, code, courses, and more by Joe Masilotti.
My first RailsConf is officially over. 😢
But I had an amazing time meeting folks IRL for the first time! If we didn’t get to say hi then let me know and I’ll make sure we meet at the next conference.
All told, I learned a lot. My favorite technical talk was from Dave Copeland on why your app needs a service layer. Not necessarily service objects, but a spot where all of your business logic lives.
I took this to heart and have been slowly refactoring the RailsDevs codebase to extract a service layer. I’m not 100% sure this will get merged in, but it is definitely fun to experiment with a new approach.
I know the word “service” gets a bad rep in the Rails world. But I think it’s worth exploring a new way to organize code every now and then.
Does your app have a service layer? Are you all in on a DSL/framework to help facilitate that? Or do you throw everything in Active Record models?
Email or DM me on Twitter with your thoughts – I’d love to hear your take!
📹 Videos
Let’s recreate Notion in Ruby on Rails - Episodes 2 + 3
by Dr Nic @drnic
Following up on last month’s video, Dr. Nic published the next 2 parts of the tutorial on recreating Notion in Rails. These episodes cover inline editing and integrating Tip Tap for rich text editing.
Real-Time Page Updates With Hotwire in Just 5 Minutes
by Cezar Halmagean (Mix & Go) @chalmagean
I’m really loving these 5 minute videos on Hotwire on the Mix & Go YouTube channel. This time we are walked through building a buddy list of sorts - a live-updating screen that shows who is currently online. Make sure to watch until the end as there is a gotcha for using this code in production.
🎓 Tutorials
Custom Turbo Stream Actions
by Roland Studer @RolandStuder
Turbo only provides 7 different Turbo Stream actions out of the box: append
, prepend
, replace
, update
, remove
, before
, and after
. But what if you want your own custom action, like redirect
? Roland walks us through how to create your own custom Turbo Stream action with a Stimulus controller and a good ol’ helper.
A Case for Query Objects in Rails
by Thiago Araújo Silva @thiagoaraujos
Query Objects have been top of mind for me since adding filtering to RailsDevs. They help keep all query-related business logic in a single model without ballooning the scope of your Active Record models. Here, Thiago walks through some steps to make your Query Objects easier to write and understand.
Infinite scrolling pagination with Rails, Hotwire, and Turbo
by Yaroslav Shmarov @yarotheslav and Phil Hayton @gotbadger
Leveraging popular pagination framework Pagy, Yaroslav and Phil progressively enhance a long list of items with Hotwire. What starts out as a button to load more results eventually becomes an infinitely scrolling list. There’s also a bonus section on building your own pagination without a third-party library.
Dynamic “Like” button without JavaScript
by Guillaume @guillaumebriday
An entire tutorial all in a single Tweet-able image! What a flex from Turbo Streams that we can build something so dynamic without a single line of JavaScript.
🌏 Community
2022 Ruby on Rails Community Survey Results
by Planet Argon @planetargon
The survey results are in! Every year Planet Argon runs the Ruby on Rails Community survey and this year they received over 2,500 responses. As always, they compare results to previous surveys with nice graphs and charts. I’m still diving in to all the results but there is a lot to learn here.
🙋♂️ Some personal updates
I took a hiatus from client work this month to focus on my side businesses. And boy have I been busy!
- Jumpstart Pro iOS got 11 new features and a script to get you started faster
- RailsDevs had 25+ PRs merged and still has 10+ open issues up for grabs
- RailsConf inspired a long list of things I want to do
- I drafted an outline of my Turbo Native workshop
I’d love to know what you think about this edition – please send me an email or DM me on Twitter. That’s all from me – see you next month!
