Yes, you should terminate the go block in will-unmont, otherwise if your component is mounted multiple times, you will end up with multiple go blocks consuming from the channel. If you are transacting on a cursor, then this will just eat up resources, but if you are accessing owner (eg to get/set local state) then you also risk accessing stale react components.
I personally use an om-tools mixin to handle both subscribing and unsubscribing to core.async pubs. This way I don't have to remember to unsubscribe in unmount myself. On 30 October 2014 18:01, Colin Yates <[email protected]> wrote: > (om/core.async newbie warning) > > I see a common pattern (including in the om tutorials) of using channels > to communicate. Specifically I see code similar to: > > [code] > om/IWillMount > (will-mount [_] > (let [nav (om/get-shared owner :nav-chan)] > (go (loop [] > (let [page (<! nav)] > (om/transact! app :page (fn [x] page)) > (recur)))) > [/code] > > What happens when that component is unmounted? Do I need to stop listening > to that channel and if so how do I do that? > > I am not claiming there is a problem, I am simply asking if there is a > potential problem and for clarity on the mechanics. > > For context, I am mounting/unmounting quite a bit as they navigate through > the app. > > Thanks! > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
