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
From my reading of the documentation, the class method broadcasts should configure the model to broadcast creates, updates, and destroys to a stream name automatically set to the current model. I would expect the broadcasts to be made to a stream name derived from the model name pluralised, although the pluralisation is not documented explicitly.
In any case, the actual implementation broadcasts to a stream name derived from the GlobalID of the model instance. This makes little sense because although a partial can be configured to accept broadcasts from this unique stream name, updates will replace the target element as expected, destroys will leave an orphaned turbo-cable-stream-source tag behind and creating a new model instance has no effect because the broadcast will be made to a channel name that does not exist at the time of rendering.
What are community's thoughts on this?
Apologies if this is the wrong place to ask.
The text was updated successfully, but these errors were encountered:
(Briefly, though, I think what you’re describing is, say, broadcasts_to :posts. That’s not what broadcasts is for. Imagine you had a post that had comments that broadcasts_to :posts, but it’s important, for some reason, to broadcast when the title of the post changes. That’s when you’d reach for broadcasts. The <%= turbo_stream_from @post %> call in your template would pick up both the comments and the change to the post itself. And it would only be the changes to, and the comments for, that specific post, because the stream is scoped by the ID.)
From my reading of the documentation, the class method
broadcasts
should configure the model to broadcast creates, updates, and destroys to a stream name automatically set to the current model. I would expect the broadcasts to be made to a stream name derived from the model name pluralised, although the pluralisation is not documented explicitly.In any case, the actual implementation broadcasts to a stream name derived from the
GlobalID
of the model instance. This makes little sense because although a partial can be configured to accept broadcasts from this unique stream name, updates will replace the target element as expected, destroys will leave an orphanedturbo-cable-stream-source
tag behind and creating a new model instance has no effect because the broadcast will be made to a channel name that does not exist at the time of rendering.What are community's thoughts on this?
Apologies if this is the wrong place to ask.
The text was updated successfully, but these errors were encountered: