Created
May 17, 2013 12:38
-
-
Save pasviegas/5598761 to your computer and use it in GitHub Desktop.
Reactor - Clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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