Closed henrydjacob closed 4 years ago
Hey @henrydjacob
Yes, you can use CableReady for that. In your controller, you will have to include CableReady::Broadcaster
class MessagesController < ApplicationController include CableReady::Broadcaster
# POST /messages def create @message = Message.create(message_params) cable_ready["timeline:#{@message.project.id}"].insert_adjacent_html( selector: "#timeline", position: "afterbegin", html: render_to_string(partial: 'message', locals: { message: @message }) ) cable_ready.broadcast end
I hope this helps. You can read more about it here: https://cableready.stimulusreflex.com/
This is great, can we also subscribe to a specific room and send these updates only to those users who are subscribed
Exactly! You get the 💡 now.
Hey @henrydjacob
Yes, you can use CableReady for that. In your controller, you will have to include CableReady::Broadcaster
I hope this helps. You can read more about it here: https://cableready.stimulusreflex.com/