mirror of
https://github.com/penpot/penpot.git
synced 2025-06-05 13:01:40 +02:00
39 lines
1.1 KiB
Clojure
39 lines
1.1 KiB
Clojure
(ns uxbox.util.debug
|
|
"Debugging utils")
|
|
|
|
(def debug-options #{:bounding-boxes :group :events :rotation-handler :selection-center #_:simple-selection })
|
|
|
|
(defonce ^:dynamic *debug* (atom #{}))
|
|
|
|
(defn debug-all! [] (reset! *debug* debug-options))
|
|
(defn debug-none! [] (reset! *debug* #{}))
|
|
(defn debug! [option] (swap! *debug* conj option))
|
|
(defn -debug! [option] (swap! *debug* disj option))
|
|
|
|
(defn ^:export debug? [option] (@*debug* option))
|
|
|
|
(defn ^:export toggle-debug [name] (let [option (keyword name)]
|
|
(if (debug? option)
|
|
(-debug! option)
|
|
(debug! option))))
|
|
(defn ^:export debug-all [name] (debug-all!))
|
|
|
|
(defn ^:export tap
|
|
"Transducer function that can execute a side-effect `effect-fn` per input"
|
|
[effect-fn]
|
|
|
|
(fn [rf]
|
|
(fn
|
|
([] (rf))
|
|
([result] (rf result))
|
|
([result input]
|
|
(effect-fn input)
|
|
(rf result input)))))
|
|
|
|
(defn ^:export logjs
|
|
([str] (tap (partial logjs str)))
|
|
([str val]
|
|
(js/console.log str (clj->js val))
|
|
val))
|
|
|
|
|