htmx-extensions
htmx-extensions copied to clipboard
sse-swap improvement
Hi! In SSE extension it would be nice to have an option to specify a swapping strategy for sse-swap. With this improvement in hand it would be easy to stream back updates from the server for the users and use the data of the events as content. Thanks! :)
@zanadoman I've recently tried using htmx-sse in a simple chat app, and I've noticed how I'm unable to render the event data. I've tried using attributes:
data-hx-trigger="sse:message"
data-hx-swap="beforeend"
data-hx-target="#message-list"
But this doesnt trigger the swap. Am I correct to assume that this is not possible to implement with htmx attributes and should be done with JS, like:
document.addEventListener('htmx:sseMessage', (event) => {
if (event.detail.type === 'message') {
document.querySelector('#message-list').insertAdjacentHTML('beforeend', event.detail.data);
}
});
Is your proposal related to this issue, or am I misunderstanding?