Hotwire Discussion

Count turbo_stream subscribers

Hi everyone!

I’ve implemented a very simple chat application and I would like to display how many people are connected to it. Also, this number should be updated upon new access (subscribed) and when user closes the tab (unsubscribed the channel).

Is there any way I can count how many subscribers have subscribed from a turbo_stream without using ActionCable adapter methods, i.e., agnostic of Redis/Async/etc. ?

I have a feeling I should be using ActionCable methods as Turbo Stream descend from it, but I am not sure

Turbo::StreamsChannel.superclass
=> ActionCable::Channel::Base

Any feedback is welcomed!
Thanks

1 Like

Hi, did you ever find a solution for this? I’m looking for an answer to the same question.

:musical_note:and still haven’t found what i’m looking for :musical_note:

Thanks. I’ve been scouring the documentation but haven’t been able to find a clear solution.

It’d be really useful to count the number of connected subscribers - I don’t want to bother rendering a complex stream if there are 0 connected subscribers.