symfony/mercure-bundle

Documentation about pub/sub

Closed this issue · 1 comments

Documentation and examples are showing how to use Mercure from one place. But with Stimulus, each controller could listen to different topics.

What would be the best practice? Is there a recommended pub/sub library that would share the connection and work nicely with Stimulus?

Note that I assumed opening multiple SE connections hurts the server. I don't know if browsers are smart enough to internally share the connection if the URL has already been used.

Never mind, found the solution.

If anyone stumbles on this:

you don't need to open individual topics like examples in Symfony docs. All that is needed is to add single <span {{ turbo_stream_listen('public') }} ></span> and whatever you publish to public, any stream ID you want, it will update them.

Mercure works way better than expected.