stimulusreflex / stimulus_reflex

Build reactive applications with the Rails tooling you already know and love.
https://docs.stimulusreflex.com
MIT License
2.28k stars 172 forks source link

Shared connections to reduce websocket connections? #136

Closed jonathan-s closed 4 years ago

jonathan-s commented 4 years ago

Feature Request

I think that the current case is that if you opened up several tabs with the same stimulusreflex controller you would end up with multiple websocket connections, this is a bit wasteful. So at some point it might be worth exploring how this can be minimized.

A starting point might be to check out this -> https://blog.pusher.com/reduce-websocket-connections-with-shared-workers/

leastbad commented 4 years ago

I’m pretty sure that this would actually be a change most appropriately made to the ActionCable JS library, not StimulusReflex. It seems like we could import a worker version of consumer.js.

As interesting as this is, it’s not something we’re likely to take on but we’d be very supportive if you do.

jonathan-s commented 4 years ago

That's fair enough. I'll keep this issue as a reminder for myself. :)

leastbad commented 4 years ago

Have you checked out the ActionCable repo? It’s highly possible that someone has built this, and we’d be thrilled.

hopsoft commented 4 years ago

Neat solution; though, it definitely belongs in ActionCable.

leastbad commented 4 years ago

@jonathan-s As this isn't likely to be implemented within StimulusReflex, would you mind closing this issue?

jonathan-s commented 4 years ago

closing this then. and you are both right that it would make more sense in actioncable.