Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clojure core.async example 2
(ns async2
(:require [clojure.core.async :as async]
[clojure.core.async.lab :as lab]))
(defn make-fb-group [& members]
(apply lab/broadcast members))
(defn alice [c]
(async/>!! c "Dave Davenson's House @ 10pm"))
(defn bob []
(let [c (async/chan 1)]
(async/go (println "Bob received: " (async/<! c)))
c))
(defn carol []
(let [c (async/chan 1)]
(async/go (println "Carol received: " (async/<! c)))
c))
(let [fb-group (make-fb-group (bob) (carol))]
; Alice sends the message to the group
(alice fb-group))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment