That looks great Dan! here's a slightly different version that takes a supplied channel and kills the go on either component unmount or the supplied channel being closed
(defmixin go-block-aware (init-state [] {:chans {:mounted (async/chan)}}) (will-unmount [owner] (async/close! (om/get-state owner [:chans :mounted]))) (go [owner read-chan callback] (let [mounted (om/get-state owner [:chan :mounted])] (go-loop [] (when-some [v (first (async/alts! [read-chan exit-chan]))] (callback v) (recur)))))) I've used something like this before with mult/tap (defn create-mults [chans] {:chans chans :mults (zipmap (keys chans) (map mult (vals chans)))}) (defn get-shared-chan [owner key] (om/get-shared owner [:chans key])) (defn tap-shared-chan ([owner key] (tap-shared-chan owner key (async/chan))) ([owner key ch] (tap (om/get-shared owner [:mults key]) ch))) (om/root app-view app-state {:target (.getElementById js/document "app") :shared (create-mults {:nav (chan) :events (chan)})}) and then in your component you could use something like what Dan suggests (defcomponentk a-component [owner] (:mixins go-block-aware) (did-mount [_] (.go owner (tap-shared-chan owner :nav) (fn [v] ...))) (render [_] ...)) I usually then submit tuples to the shared channels and then destructure (fn [[action & args] (case action :login (let [[id] args] (do-login id))]) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.