mirror of
https://github.com/penpot/penpot.git
synced 2025-06-05 23:21:38 +02: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/buffer 2 1)
|
||||||
(rx/map coords-delta)))
|
(rx/map coords-delta)))
|
||||||
|
|
||||||
(define-once
|
(define-once :mouse-subscriptions
|
||||||
(as-> mouse-delta-s $
|
(as-> mouse-delta-s $
|
||||||
(rx/filter #(deref shapes-dragging?) $)
|
(rx/filter #(deref shapes-dragging?) $)
|
||||||
(rx/on-value $ (fn [delta]
|
(rx/on-value $ (fn [delta]
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
:width (- current-x start-x)
|
:width (- current-x start-x)
|
||||||
:height (- current-y start-y)}))
|
:height (- current-y start-y)}))
|
||||||
|
|
||||||
(define-once
|
(define-once :selrect-subscriptions
|
||||||
(let [ss (as-> (rx/from-atom selrect-dragging?) $
|
(let [ss (as-> (rx/from-atom selrect-dragging?) $
|
||||||
(rx/dedupe $)
|
(rx/dedupe $)
|
||||||
(rx/merge $ (rx/of false))
|
(rx/merge $ (rx/of false))
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
(events/unlistenByKey key)
|
(events/unlistenByKey key)
|
||||||
(.clearKeyListener handler)))))
|
(.clearKeyListener handler)))))
|
||||||
|
|
||||||
(define-once
|
(define-once :subscriptions
|
||||||
(rx/on-value +stream+ #(println "[debug]: shortcut:" %))
|
(rx/on-value +stream+ #(println "[debug]: shortcut:" %))
|
||||||
(rx/on-value +stream+ (fn [event]
|
(rx/on-value +stream+ (fn [event]
|
||||||
(when-let [handler (get +shortcuts+ event)]
|
(when-let [handler (get +shortcuts+ event)]
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
(:refer-clojure :exclude [defonce]))
|
(:refer-clojure :exclude [defonce]))
|
||||||
|
|
||||||
(defmacro define-once
|
(defmacro define-once
|
||||||
[& body]
|
[name' & body]
|
||||||
(let [sym (gensym "uxbox-")]
|
(let [sym (symbol (str (namespace name') "-" (name name')))]
|
||||||
`(cljs.core/defonce ~sym
|
`(cljs.core/defonce ~sym
|
||||||
(do ~@body
|
(do ~@body nil))))
|
||||||
nil))))
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue