Currently, some JavaScript is needed to connect a Turbo Stream to an EventSource (SSE) or WebSocket (by the way, the docs aren't very clear about how to do this).
It would be superb if it could be done without JavaScript, rather using an incantation of the turbo-stream custom element.
Current imperative mechanism:
(window['EventSource'] && window['Turbo']) ?
Turbo.connectStreamSource(new EventSource('/my-turbo-stream')) :
console.warn('Turbo Streams over SSE not available');
Suggested declarative mechanism:
<turbo-stream src="/my-turbo-stream">
If the URL scheme was ws: then Turbo would create a new WebSocket, otherwise it would be an EventSource.
The addition of a src attribute to the custom turbo-stream tag need not (but may) be conflated with the use of it in directives to altering the DOM as content arrives on the stream or as the result of a form submission (i.e. the existing capabilities of the custom tag).
Currently, some JavaScript is needed to connect a Turbo Stream to an EventSource (SSE) or WebSocket (by the way, the docs aren't very clear about how to do this).
It would be superb if it could be done without JavaScript, rather using an incantation of the
turbo-streamcustom element.Current imperative mechanism:
Suggested declarative mechanism:
If the URL scheme was
ws:then Turbo would create a newWebSocket, otherwise it would be anEventSource.The addition of a
srcattribute to the customturbo-streamtag need not (but may) be conflated with the use of it in directives to altering the DOM as content arrives on the stream or as the result of a form submission (i.e. the existing capabilities of the custom tag).