mirror of
https://github.com/penpot/penpot.git
synced 2025-04-05 19:41:27 -05:00
Minor refactor of define-once macro.
This commit is contained in:
parent
936fd3b070
commit
a2401a4d7a
3 changed files with 6 additions and 7 deletions
|
@ -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))
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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))))
|
||||
|
|
Loading…
Add table
Reference in a new issue