Turbo::StreamsChannel can set targets attribute on stream tag#210
Merged
dhh merged 2 commits intohotwired:mainfrom Aug 26, 2021
Merged
Turbo::StreamsChannel can set targets attribute on stream tag#210dhh merged 2 commits intohotwired:mainfrom
dhh merged 2 commits intohotwired:mainfrom
Conversation
Member
|
👍. Can you add some tests for this as well? |
Background: - hotwired/turbo#113 allowed for multiple targets in turbo frame streams. - hotwired#194 implemented it for `Turbo::Streams::TagBuilder` This attempts to expose the feature on `Turbo::StreamsChannel` methods.
Contributor
Author
|
Hi @dhh, sure I can do it. I have three different approaches in mind:
Something like: with_target_options do |opts|
assert_broadcast_on "stream", turbo_stream_action_tag("replace", template: "<p>hello!</p>", **opts) do
Turbo::StreamsChannel.broadcast_replace_to "stream", partial: "messages/message", locals: { message: "hello!" }, **opts
end
endI think covering the uses cases that match with What do you think? |
Closed
Member
|
Think just adding another assert with the targets argument is fine. Doesn't need to be too clever! |
550cba5 to
795a3b3
Compare
795a3b3 to
b8efbb1
Compare
ghiculescu
added a commit
to ghiculescu/turbo-rails
that referenced
this pull request
Dec 9, 2022
hotwired#210 added the ability to set `targets` on a stream tag. But that doesn't work nicely with the `Broadcastable` helper methods. Currently you have to do this to target some `targets`: ```ruby after_update_commit -> { broadcast_update_to self, target: nil, targets: ".class_name" } ``` This PR improves things so that you don't need to provide `target: nil` anymore.
ghiculescu
added a commit
to ghiculescu/turbo-rails
that referenced
this pull request
Dec 9, 2022
hotwired#210 added the ability to set `targets` on a stream tag. But that doesn't work nicely with the `Broadcastable` helper methods. Currently you have to do this to target some `targets`: ```ruby after_update_commit -> { broadcast_update_to self, target: nil, targets: ".class_name" } ``` This PR improves things so that you don't need to provide `target: nil` anymore.
ghiculescu
added a commit
to ghiculescu/turbo-rails
that referenced
this pull request
Dec 9, 2022
hotwired#210 added the ability to set `targets` on a stream tag. But that doesn't work nicely with the `Broadcastable` helper methods. Currently you have to do this to target some `targets`: ```ruby after_update_commit -> { broadcast_update_to self, target: nil, targets: ".class_name" } ``` This PR improves things so that you don't need to provide `target: nil` anymore.
ghiculescu
added a commit
to ghiculescu/turbo-rails
that referenced
this pull request
Dec 9, 2022
hotwired#210 added the ability to set `targets` on a stream tag. But that doesn't work nicely with the `Broadcastable` helper methods. Currently you have to do this to target some `targets`: ```ruby after_update_commit -> { broadcast_update_to self, target: nil, targets: ".class_name" } ``` This PR improves things so that you don't need to provide `target: nil` anymore.
JuannFerrari
added a commit
to JuannFerrari/turbo-rails
that referenced
this pull request
Nov 9, 2023
hotwired#210 added the ability to set `targets` on a stream tag. But that doesn't work nicely with the `Broadcastable` helper methods. Currently you have to do this to target some `targets`: ```ruby after_update_commit -> { broadcast_update_to self, target: nil, targets: ".class_name" } ``` This PR improves things so that you don't need to provide `target: nil` anymore. -- This PR is a continuation of the work made by @ghiculescu at PR turbo-rails#408
This was referenced Nov 9, 2023
dhh
pushed a commit
that referenced
this pull request
Sep 16, 2024
* @ghiculescu: #210 added the ability to set `targets` on a stream tag. But that doesn't work nicely with the `Broadcastable` helper methods. Currently you have to do this to target some `targets`: ```ruby after_update_commit -> { broadcast_update_to self, target: nil, targets: ".class_name" } ``` This PR improves things so that you don't need to provide `target: nil` anymore. -- This PR is a continuation of the work made by @ghiculescu at PR turbo-rails#408 * Add specs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background:
Turbo::Streams::TagBuilderThis attempts to expose the feature on
Turbo::StreamsChannelmethods.