-
-
Save gabehollombe/b195e5c725784ee1bb54 to your computer and use it in GitHub Desktop.
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 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