From the Rails Guide I found following three code snippets
ActionCable.server.broadcast("chat_#{params[:room]}", data)
This simple broadcast sends the data to a specific chat room
while broadcast_to
as shown below seems to send data to all chatrooms within a channel to which current user is subscribed .
WebNotificationsChannel.broadcast_to(
current_user,
title: 'New things!',
body: 'All the news fit to print'
)
Here is another type of broadcast broadcast_for - for which i couldn't get any example .
My question is what is actual difference between these three and when to use each of 'em - thanks in advance