Search code examples
clojure

disconnecting a manifold stream without closing other streams


If I create two streams and connect the two:

(def a (stream/stream))
(def b (stream/stream))
(stream/connect a b)

When 'a' is closed 'b' closes

(stream/closed? b) => false
(stream/close! a)
(stream/closed? b) => true

Is there a way to disconnect 'a' from 'b' without closing 'b'?


Solution

  • Yes, there is. According to the doc of stream/connect:

    Optionally takes a map of parameters:

    ...

    • downstream? - if closing the source will close the sink. Defaults to true.

    ...

    So, you need to connect your streams as follows:

    (stream/connect a b {:downstream? false})