You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, a broadcast is generated by User.last.save!, even though there are no changes to the model or the database. With many save! calls across models that aren't actually changed, this can result in lots of seemingly wasteful jobs.
There seems to be clear solution to this that doesn't involve reimplementing broadcasts_refreshes and setting up the same *_commit callbacks manually:
For example, there's no callback mechanism (like a sort of around_commit) to wrap the code in suppressing_turbo_broadcasts {}. Moreover, User.last.touchshould fire a change, so inspecting, e.g., has_changes_to_save? isn't quite correct. There's a gem, ar_transaction_changes, which helps with this.
It'd be great to have a simple way to do this!
A sort-of workaround using the ar_transaction_changes gem, but it feels a little hacky (also note it relies on Rails 7.1's callback ordering behavior):
Suppose
User
broadcasts refreshes:Currently, a broadcast is generated by
User.last.save!
, even though there are no changes to the model or the database. With manysave!
calls across models that aren't actually changed, this can result in lots of seemingly wasteful jobs.There seems to be clear solution to this that doesn't involve reimplementing
broadcasts_refreshes
and setting up the same*_commit
callbacks manually:For example, there's no callback mechanism (like a sort of
around_commit
) to wrap the code insuppressing_turbo_broadcasts {}
. Moreover,User.last.touch
should fire a change, so inspecting, e.g.,has_changes_to_save?
isn't quite correct. There's a gem, ar_transaction_changes, which helps with this.It'd be great to have a simple way to do this!
A sort-of workaround using the ar_transaction_changes gem, but it feels a little hacky (also note it relies on Rails 7.1's callback ordering behavior):
The text was updated successfully, but these errors were encountered: