wayne
wayne copied to clipboard
SSE should support event names
I am using wayne along with htmx and I would like elements to subscribe for specific events as in docs
<div hx-sse="connect:/sse">
<div hx-sse="swap:eventName1">
...
</div>
<div hx-sse="swap:eventName2">
...
</div>
</div>
then accordingly broadcast named events
app.get('/sse', function(req, res) {
//...
stream.send({ name: 'eventName1', data: '' } );
});
According to Server-Sent Events spec the name of the event is event: not name:.
See this tutorial https://javascript.info/server-sent-events#event-types
So you need:
stream.send({ event: 'eventName1', data: '' });