immutant.web.sse

Provides Server-Sent Events via immutant.web.async/as-channel

as-channel

Decorates the result of immutant.web.async/as-channel with the proper SSE Content-Type.

Event

protocol

members

event->str

(event->str x)

Formats event according to SSE spec

send!

(send! ch event & options)

Formats an event according to the SSE spec and sends it via immutant.web.async/send!.

event can be one of:

  • a Map, with one or more of the following keys: :event, :data, :id, and :retry, where the :data entry can be an Object or Collection
  • an Object, treated as a simple data field (sent as (str "data:" the-object "\n"))
  • a Collecton, treated as a multi-line data field

The options for this function are the same as the options for immutant.web.async/send!.

If you need different behavior for a particular type, extend it with the Event protocol.