From f745cb22d1da770da1de7ff7e153297db40cc883 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Sat, 17 Feb 2018 10:03:24 -0500 Subject: [PATCH] Use global dispatch-message function instead of let-binding --- src/sidebar/looped_in/sidebar.cljs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/sidebar/looped_in/sidebar.cljs b/src/sidebar/looped_in/sidebar.cljs index 7f26f67..647973f 100644 --- a/src/sidebar/looped_in/sidebar.cljs +++ b/src/sidebar/looped_in/sidebar.cljs @@ -113,9 +113,11 @@ #(assoc % :loading (:loading msg))) @state)) +(declare dispatch-message) + (defn view "Given a callback to dispatch an update message and the sidebar state, returns the sidebar DOM" - [dispatch-message state] + [state] (cond (:loading state) (list (components/sidebar-header (components/with-classes (components/header-icon "icons/icon48.png") @@ -236,7 +238,7 @@ (defn handle-events "Registers event listeners" - [dispatch-message state] + [state] (events/listen (dom/getElement "closeSidebar") "click" handle-close-button) (when (not (nil? (dom/getElement "backButton"))) (events/listen (dom/getElement "backButton") @@ -250,15 +252,17 @@ (declare run-render-loop) -(defn dispatch-message [msg] +(defn dispatch-message + "Dispatches a message to change the state" + [msg] (let [new-state (update-state msg)] (run-render-loop new-state))) (defn run-render-loop "Runs the model-update-view loop" [state] - (render (view dispatch-message state)) - (handle-events dispatch-message state)) + (render (view state)) + (handle-events state)) (defn fetch-hits "Fetch hits in the Algolia API matching the URL"