Hi guys! What is the convention to adopt in the codebase with a lot of missionary task? For example consider the following example:
;; Let the caller apply the missionary wrapper
(defn function-1 [] ...)
(def main
(m/sp
(let [res-1 (m/? (m/sp (function-1)))]
;; Or provide extra function to do the job
(defn function-1 [] ...)
(defn ?function-1 [] (m/? (m/sp (function-1)))
(def main
(m/sp
(let [res-1 (?function-1)])
Let the caller choose. It's always possible to turn an asynchronous task into a synchronous one but the opposite is not true, so async should be the default
Is there a simple way to merge discrete flows: to create an output flow which outputs all values from inputs flows as they occur? I could have the input flows publish to a mbx and construct the output flow from the values fetched from the mbx. The output flow should terminate when all input flows have terminated, so perhaps an input flow would publish a special terminated message to the mbx on terminating, the output process would count the termination messages and terminate when it got the same number of termination messages as input flows. Is there a simpler way to do this?
yes, this one
This seems to work, but why doesn't it go into an infinite loop when the inputs flows terminate?
(defn merge-flows [>i1 >i2]
(m/ap
(loop []
(m/amb
(m/amb= (m/?> >i1) (m/?> >i2))
(recur)))))oh...
(defn merge-flows [>i1 >i2]
(m/ap
(m/amb= (m/?> >i1) (m/?> >i2))))From the documentation, it looks like there isn't a way to terminate the flow created by observe ? The flow can be cancelled of course, but there isn't a way to have it act like e.g. (seed [1 2 3]), i.e. output some values and then terminate without cancellation? (It's fine if not, there's other ways to do it of course, just wanted to check my understanding).
correct