Created
January 30, 2016 17:20
-
-
Save tim-br/d9560ada0d78cee10163 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(use 'clojure.core.async) | |
(def input-chan (chan)) | |
(def our-pub (pub input-chan :msg-type)) | |
(>!! input-chan {:msg-type :greeting :text "hello"}) | |
(def output-chan (chan)) | |
(sub our-pub :greeting output-chan) | |
(go-loop [] | |
(let [{:keys [text nonce]} (<! output-chan)] | |
(println text) | |
(println nonce) | |
(recur))) | |
(>!! input-chan {:msg-type :greeting :text "hi"}) | |
(>!! input-chan {:msg-type :yolo :text "fun" :nonce "i dont know"}) | |
(sub our-pub :yolo output-chan) | |
(def publisher-chan (chan)) | |
(def publisher (pub publisher-chan #(get % 0))) | |
(def my-output-chan (chan)) | |
(sub publisher 22 my-output-chan) | |
(go-loop [] | |
(let [fun (<! my-output-chan)] | |
(println "test ") | |
(println (get fun 1)) | |
(recur))) | |
(>!! publisher-chan [22 "now of course"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment