Skip to content

Commit

Permalink
deploy: b257377
Browse files Browse the repository at this point in the history
  • Loading branch information
afcapel committed Jan 16, 2024
1 parent 0f9a3d6 commit 707a3fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion handbook/streams.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ <h2 id="progressively-enhance-when-necessary"><a class="anchor" href="#progressi
<p>The same is especially true for WebSocket updates. On poor connections, or if there are server issues, your WebSocket may well get disconnected. If the application is designed to work without it, it’ll be more resilient.</p>
<h2 id="but-what-about-running-javascript%3F"><a class="anchor" href="#but-what-about-running-javascript%3F"></a> But What About Running JavaScript?</h2>
<p>Turbo Streams consciously restricts you to seven actions: append, prepend, (insert) before, (insert) after, replace, update, and remove. If you want to trigger additional behavior when these actions are carried out, you should attach behavior using <a href="https://stimulus.hotwired.dev">Stimulus</a> controllers. This restriction allows Turbo Streams to focus on the essential task of delivering HTML over the wire, leaving additional logic to live in dedicated JavaScript files.</p>
<p>Embracing these constraints will keep you from turning individual responses in a jumble of behaviors that cannot be reused and which make the app hard to follow. The key benefit from Turbo Streams is the ability to reuse templates for initial rendering of a page through all subsequent updates.</p>
<p>Embracing these constraints will keep you from turning individual responses into a jumble of behaviors that cannot be reused and which make the app hard to follow. The key benefit from Turbo Streams is the ability to reuse templates for initial rendering of a page through all subsequent updates.</p>
<h2 id="custom-actions"><a class="anchor" href="#custom-actions"></a> Custom Actions</h2>
<p>By default, Turbo Streams support <a href="/reference/streams#the-seven-actions">seven values for its <code>action</code> attribute</a>. If your application needs to support other behaviors, you can override the <code>event.detail.render</code> function.</p>
<p>For example, if you’d like to expand upon the seven actions to support <code>&lt;turbo-stream&gt;</code> elements with <code>[action=&quot;alert&quot;]</code> or <code>[action=&quot;log&quot;]</code>, you could declare a <code>turbo:before-stream-render</code> listener to provide custom behavior:</p>
Expand Down

0 comments on commit 707a3fa

Please sign in to comment.