wayne icon indicating copy to clipboard operation
wayne copied to clipboard

SSE should support event names

Open 7flash opened this issue 1 year ago • 1 comments

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: '' } );
});

7flash avatar May 31 '24 04:05 7flash

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: '' });

jcubic avatar May 31 '24 10:05 jcubic