In my Rails view I’m using turbo_stream_from
to subscribe to a turbo stream broadcast to display a list of patients:
<%= turbo_stream_from :all_patients %>
I want this list to be updated when a new patient is created, so I call:
constly_method
Turbo::StreamsChannel.broadcast_update_to(:all_patients,...)
However, I want to run this code only if there are any clients that are actually subscribed to :all_patients
at the moment, because this code takes some computing resources. So, I want something like
if Turbo::StreamsChannel.broadcast_subscribed?(:all_patients)
constly_method
Turbo::StreamsChannel.broadcast_update_to(:all_patients,...)
end
Is there any way to check that?