0

We are facing a scenario where we want to ensure that the identified connections can view the newly created resource before we broadcast it to each connection within Action Cable. After reading some documentation, it appeared possible to broadcast to a specific connection only. Here is the code we are currently using:

ActionCable.server.connections.each do |connection| 
  Identity.roles.keys.each do |role|
    Turbo::StreamsChannel.broadcast_append_to connection, target: "submissions", partial: "submissions/replace_#{role}_submission", locals: { submission: self }
  end
end

This code is producing a turbo stream output but it doesn't seem to be displaying on the page when called. Here is the output:

[ActionCable] Broadcasting to #<ApplicationCable::Connection:0x0000000112b47900>

But that doesn't seem to send back the stream to the connection. If I replace the connection with the room, then this code properly works.

QUESTION:

Is it possible to broadcast a turbo stream response to each and every connection within Action Cable? Additionally, is this ill-advised, if possible?

Bitwise
  • 8,021
  • 22
  • 70
  • 161

0 Answers0