Fork me on GitHub
#core-async
<
2016-07-15
>
achesnais08:07:15

Wondering – what would be the best way to manage go-loops, especially within a reloaded workflow? Currently my approach was to just def whatever loops needed to run continually in my programme – but when I reload my repl they don't die. Any best practices around this?

mccraigmccraig08:07:31

@achesnais: hold refs to channels in a lifecycle component, and close the channels when the component is stopped... your go loops will read nil and can terminate

achesnais08:07:23

makes sense – thanks for the prompt answer!

dominicm09:07:49

I implemented my component using a "kill channel" this is a channel that the component creates and listens to using alts!. It means that the component can close independently of the input channel closing. Just an alternative idea/implementation

ghadi15:07:07

having a global channel registry a la clojure.spec's registry is a potentially useful approach

ghadi15:07:14

if you can give meaningful names to your channels:

{[:subsystem/mail #uuid 1234..... ]   chan 
...
 }