Symfony UX: Turbo
Smartly Updating Elements for all Users
  Start your All-Access Pass to unlock this challenge
Buy Access Login

Challenge 1 / 1

In my chat application, whenever a user sends a message to the chat, I return a turbo stream message to update all of the user's pages with the new message. My stream code looks like this:

<turbo-stream action="update" id="new-messages-{{ chat.id }}">
    <template>
        {% for message in chat.newMessages %}
            <div class="message">
                <span class="user">{{ message.from }}</span>:
                {{ message.text }}
            </div>
        {% endfor %}
    </template>
</turbo-stream>

But whenever a user sends a message, the entire chat room disappears and only shows the last messages. Why? And how can I fix it?

Skip challenges and go to theNext Chapter

Turn Challenges Off?

All further challenges will be skipped automatically.
You can re-enable challenges at any time on this page or from your account page.