Hotwire components that refresh themselves
Using ViewComponents that know how to refresh themselves via turbo_streams is a powerful pattern to build complex flows with Hotwire
Earlier this year I made a tweet about a pattern for interactive Hotwire features that people seemed to like:
With the help of my friend Jesper, we turned this into a full article as there were some questions about some of the details in the thread.
Key takeaways from me:
Using components (ViewComponent or Phlex) is a much nicer experience than standard Rails partials for turbo streaming
Wrapping logic like dom_ids and broadcast channels in the component is good — even if it slightly offends some SRP purists
People are still sleeping on `UI` namespace for components!
👉 Read it here: Hotwire components that refresh themselves
📣 Thoughts? Join the discussion on Twitter
Stay boring!
- Matt