Skip to content

Instantly share code, notes, and snippets.

;; A basic Ring handler
(defn handler [request]
{:status 200
:headers {}
:body "Hello World"})
;; Which can also be written:
(def handler
@Chouser
Chouser / gist:3687532
Created September 9, 2012 21:52
Lazy seq as event subscription mechanism
;; Here is a spike of a lightweight in-process pubsub mechanism that allows pure ;; functional consumers, both blocking and asynchronous.
;; This defines the event stream, in this case just a series of numbers,
;; a new one produced each second
(defn timer []
(lazy-seq
(do
(Thread/sleep 1000)
(cons (System/nanoTime) (timer)))))