Fix sending created broadcasts refreshes to channels where no one listens #521
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed
broadcasts_refreshes
method was added that sets up the model hooks to send broadcasts refreshes automatically. However, it repeats the same issue previously found in thebroadcasts
method (Turbo::Broadcastable#broadcasts broadcasts creates to model_name.plural stream #295) where it sends the creation broadcasts to the current model's channel and defaults to, but no one will ever be listening on that. This PR allows passing astream
param tobroadcasts_refreshes
method, which will be used as the channel name when broadcasting refreshes on model creation and defaults to the model's plural name, similar to how thebroadcasts
method works. It also sends the broadcast refresh right away instead of later when the model is deleted.