Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/channels/turbo/streams/broadcasts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ def broadcast_stream_to(*streamables, content:)
end
end

def broadcast_stream_later_to(*streamables, content:)
Turbo::Streams::BroadcastStreamJob.perform_later stream_name_from(streamables), content: content
end

def refresh_debouncer_for(*streamables, request_id: nil) # :nodoc:
Turbo::ThreadDebouncer.for("turbo-refresh-debouncer-#{stream_name_from(streamables.including(request_id))}")
end
Expand Down
8 changes: 8 additions & 0 deletions test/streams/streams_channel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ class Turbo::StreamsChannelTest < ActionCable::Channel::TestCase
end
end

test "broadcasting direct update later" do
assert_broadcast_on "stream", %(direct) do
perform_enqueued_jobs do
Turbo::StreamsChannel.broadcast_stream_later_to "stream", content: "direct"
end
end
end

test "broadcasting actions with method morph now" do
options = { attributes: { method: :morph }, partial: "messages/message", locals: { message: "hello!" } }

Expand Down
Loading