Skip to content

Instantly share code, notes, and snippets.

@pasviegas
Created May 17, 2013 12:38
Show Gist options
  • Save pasviegas/5598761 to your computer and use it in GitHub Desktop.
Save pasviegas/5598761 to your computer and use it in GitHub Desktop.
Reactor - Clojure
(ns reactor.clj.core
(:import [reactor.core Reactor Context]))
;;create the reactor
(def reactor (Reactor. (Context/rootDispatcher)))
;;create the selector
(def selector (reactor.Fn/$ "print.received"))
;;create and implement the consumer
(def consumer (proxy [reactor.fn.Consumer][] (accept [event] (println "Received"))))
(defn -main
"Prints Received"
[& args]
;; attach consumer to the selector
(.on reactor selector consumer)
;; notify!!
(.notify reactor "print.received" (reactor.Fn/event nil)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment