https://github.com/bobby/ring-sse

ring-sse is a small library implementing Server-Sent Events 
<https://www.w3.org/TR/2009/WD-eventsource-20090423/> as an asynchronous 
Ring 
<https://github.com/ring-clojure/ring/blob/033a3235212dc71151c8e8c05069cb6c2dd85bdc/SPEC>
 (spec 
1.4+) handler.  This library is based on the excellent implementation in 
Pedestal 
<https://github.com/pedestal/pedestal/blob/master/service/src/io/pedestal/http/sse.clj>,
 
and is released under the MIT license.

This is a new library, so feedback (here is good) and bug reports (as 
GitHub issues) are appreciated.

## Installation

``` clojure
[ring-sse/ring-sse "0.2.3"]
```

## Usage

``` clojure
(require '[ring.sse :as sse])

(def handler
  (sse/event-channel-handler
   (fn [request response raise event-ch]
     (a/go
       (dotimes [i 20]
         (let [event {:id   (java.util.UUID/randomUUID)
                      :name "foo"
                      :data (json/generate-string {:foo "bar"})}]
           (a/>! event-ch event)
           (a/<! (a/timeout 1000))))
       (a/close! event-ch)))
   {:on-client-disconnect #(log logger :info :sse/on-client-disconnect %)}))

;; invoked by an async adapter
(handler request respond-fn raise-fn)
```

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to