Is mult /`tap` the correct way to "keep" a value from a core.async operation so that it can be used by multiple go-blocks?
The workflow I am thinking of looks something like this:
(let [fetch-result (do-work-that-returns-chan x y)
action-1 (go (-> fetch-result
(<!)
(do-work-1)))
action-2 (go (-> fetch-result
(<!)
(do-work-2))
])
where the actions can be async. Of course, I could put all the action inside one go block, but then I'd have to put together things that I would like to be able to test separately, and it just doesn't seem ideal/composable.in this situation I'd lean towards something like this instead:
(go
(let [result (<! (do-work-that-returns-chan x y))
action-1 (go (-> result (do-work-1)))
action-2 (go (-> result (do-work-2)))]
))alternatively you could use a promise-chan
(let [fetch-result-prom (a/pipe (do-work-that-returns-chan x y) (a/promise-chan))
action-1 (go (-> fetch-result-prom
(<!)
(do-work-1)))
action-2 (go (-> fetch-result-prom
(<!)
(do-work-2))
)]
)> Of course, I could put all the action inside one go block, but then I'd have to put together things that I would like to be able to test separately, and it just doesn't seem ideal/composable. Imo the ideal is to have pure functions, test those, then wrap them all where they need to "come together"