Manually triggering processing of Stream?

In learning how this all works, one aspect is eluding me. The docs say:

These elements are delivered by the server over a WebSocket or other transport to bring the application alive

Out of the box:

Turbo knows to automatically load stream elements when they arrive in response to form submissions

How are stream elements processed if received via other means? e.g. the aforementioned WebSocket?

I’m old-school, so a likely scenario for me is I wire up some jQuery AJAX to receive a payload, and the payload from the server was formatted as a Turbo Streams message with several elements. How do I connect this raw Javascript payload object into the Turbo rendering process?

1 Like

I think they’re all just <turbo-stream> elements, so if you simply add them to the bottom of <body>, they will work their magic and then vanish. That’s why new HTML has to be wrapped in <template> tags (Rails helpers do this for you)…you don’t want the HTML to get rendered by the browser until Turbo Stream processes the tags.