From c90c5e41d29f539e791b4066e0146ec554e95981 Mon Sep 17 00:00:00 2001 From: Nicholas Kariniemi Date: Thu, 7 Aug 2014 23:40:48 +0300 Subject: [PATCH] Fix bug with unmounted items crashing it Close core.async channels on unmount, check for unmounted before calling get-node in listeners --- src/cljs/grub/view/grub.cljs | 31 +++++++++++++++++++---------- src/cljs/grub/view/recipe.cljs | 24 ++++++++++++++++------ src/cljs/grub/view/recipe_list.cljs | 20 +++++++++++++++---- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/cljs/grub/view/grub.cljs b/src/cljs/grub/view/grub.cljs index 1bdf7c4..0c22a03 100644 --- a/src/cljs/grub/view/grub.cljs +++ b/src/cljs/grub/view/grub.cljs @@ -63,7 +63,8 @@ (init-state [_] (let [publisher (chan)] {:edit-state :waiting - :grub grub})) + :grub grub + :unmounted false})) om/IRenderState (render-state [_ {:keys [edit-state] :as state}] @@ -87,17 +88,27 @@ :on-change #(om/set-state! owner :grub (.. % -target -value)) :on-key-up #(when (dom/enter-pressed? %) (transition-state owner :enter))}]])) - om/IWillMount - (will-mount [_] + om/IDidMount + (did-mount [_] (let [