From a2401a4d7ad36a103f32053df9f94c0d8721d6ad Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 10 Jan 2016 23:50:10 +0200 Subject: [PATCH] Minor refactor of define-once macro. --- frontend/uxbox/ui/workspace/base.cljs | 4 ++-- frontend/uxbox/ui/workspace/shortcuts.cljs | 2 +- frontend/uxbox/util/syntax.cljc | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/uxbox/ui/workspace/base.cljs b/frontend/uxbox/ui/workspace/base.cljs index c3db3e696..b125172e3 100644 --- a/frontend/uxbox/ui/workspace/base.cljs +++ b/frontend/uxbox/ui/workspace/base.cljs @@ -89,7 +89,7 @@ (rx/buffer 2 1) (rx/map coords-delta))) -(define-once +(define-once :mouse-subscriptions (as-> mouse-delta-s $ (rx/filter #(deref shapes-dragging?) $) (rx/on-value $ (fn [delta] @@ -114,7 +114,7 @@ :width (- current-x start-x) :height (- current-y start-y)})) -(define-once +(define-once :selrect-subscriptions (let [ss (as-> (rx/from-atom selrect-dragging?) $ (rx/dedupe $) (rx/merge $ (rx/of false)) diff --git a/frontend/uxbox/ui/workspace/shortcuts.cljs b/frontend/uxbox/ui/workspace/shortcuts.cljs index f42107bcf..efb99ba98 100644 --- a/frontend/uxbox/ui/workspace/shortcuts.cljs +++ b/frontend/uxbox/ui/workspace/shortcuts.cljs @@ -47,7 +47,7 @@ (events/unlistenByKey key) (.clearKeyListener handler))))) -(define-once +(define-once :subscriptions (rx/on-value +stream+ #(println "[debug]: shortcut:" %)) (rx/on-value +stream+ (fn [event] (when-let [handler (get +shortcuts+ event)] diff --git a/frontend/uxbox/util/syntax.cljc b/frontend/uxbox/util/syntax.cljc index 312595b89..cb9fe57cd 100644 --- a/frontend/uxbox/util/syntax.cljc +++ b/frontend/uxbox/util/syntax.cljc @@ -2,8 +2,7 @@ (:refer-clojure :exclude [defonce])) (defmacro define-once - [& body] - (let [sym (gensym "uxbox-")] + [name' & body] + (let [sym (symbol (str (namespace name') "-" (name name')))] `(cljs.core/defonce ~sym - (do ~@body - nil)))) + (do ~@body nil))))