Skip to content

Instantly share code, notes, and snippets.


gabehollombe/help.clj Secret

Created Feb 2, 2016
What would you like to do?
(:require [ :as s]
[clojure.core.async :as a]))
;; Given a function get-sock that returns a manifold stream, and given a core.async destination chan
(defn get-sock [] (s/stream))
(def sock-stream (get-sock))
(def destination-chan (a/chan))
;; I can connect sock-stream's output to destination-chan's input
(s/connect sock-stream destination-chan)
;; But, if sock-stream closes, I want to make a new sock-stream and connect it to the same destination-chan
;; I can use (s/on-closed sock-stream disconnect-handler) to register a callback,
;; but how do I make disconnect-handler make a new stock-stream with a on-close callback that uses the same logic as disconect-handler
;; so that if the new sock-stream closes, a new one will be made, etc?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment