Skip to content

Instantly share code, notes, and snippets.

@gabehollombe
Created February 2, 2016 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabehollombe/b195e5c725784ee1bb54 to your computer and use it in GitHub Desktop.
Save gabehollombe/b195e5c725784ee1bb54 to your computer and use it in GitHub Desktop.
(ns private.tmp.foo
(:require [manifold.stream :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