matt swanson 😈 Profile picture
Feb 28 2 tweets 2 min read Read on X
This is really the GOAT pattern for hotwire apps

- Make a component for view logic
- When backend does something, use turbo_stream to re-render the component with new data
- Same thing when broadcasting from a job

Partials just suck with turbo_stream IMO Image
just cram all the broadcast junk into your view...then you can just refresh it from a job easily

listen for broadcasts in the component when loading Image
Image
Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with matt swanson 😈

matt swanson 😈 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @_swanson

Sep 9, 2022
Really digging this pattern for organizing different 'features' of a model.

Keeps related methods together and makes it easier to find relevant code as the codebase grows. Plus I can separate out test files by feature. Image
Example: Tasks::DueDate

Tasks originally just had a due_date field. Eventually that grew to also support relative due dates ("10 days from start"). And we wanted a handful of helpers like `due_this_week?` and `overdue?`.

100 lines in a well-name module > 100 lines in the model
We can write a bunch of tests in test/models/tasks/due_date_test that are specific to due date concerns. You don't have to work within a 500+ line mega test.

When navigating the code base, you can fuzzy find "due date" and get see all the context, all in one place
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(