Fork me on GitHub

Is there a way to trigger an end to an infinite go-loop in Clojurescript? I'm looking at this example but I want to be able to stop the loop too. Right now, I'm thinking I can do this via a "global" atom (or channel) but is this the best way?: I'm interacting with an API that provides data via a REST endpoint and I need to frequently update my frontend.


I believe a common pattern is to pass in a channel that you use to signal a shutdown with alts


Thanks Keith.. yes, I wanted to get to know the canonical way to manage this... Channels it is!

Jan K15:11:06

You can make the go-loop terminate when the input channel closes, or have a separate "exit" channel


I was also thinking along the same lines. I was wondering whether this is the way actual Cljs programmers would approach the problem. Thanks for your answer!!