This is a quick prototype / workaround for the problem described here: symfony/ux#1331
Please use this more as guide and use your own judgement to make necessary changes for your purposes
- Remove original SF UX Turbo TwigBroadcaster
- Add own implementation and save all render parameters in a cache pool with some random key
- Send random key to all connected clients
- UpdateListenerController is a Stimulus Controller which will receive the keys
- Clients receive the message with the key and throttles (25ms) a fetch request with all keys within the throttle time
- Controller receives keys and renders the turbo-streams as usual in the user session (with very basic deduplication for rendering)
- Client receives turbo updates which are passed to
renderStreamMessage
which triggers the usual turbo updates
UpdateListenerController also refreshes the cookie after 59min as the mercure authorization JWT usually is only valid for 1h. It's quite hacky as it just fetches the current URL to refresh the cookies and then reconnects the EventSource. This should be implemented in a nicer way for production...