Skip to content

Commit 4fb44f9

Browse files
committed
Use proper type->id
1 parent ffd86f1 commit 4fb44f9

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/cljfx/dev/validation.clj

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
(in-ns 'cljfx.dev)
22

3-
(defn- type->string [fx-type]
4-
(str (or (*type->id* fx-type) fx-type)))
3+
(defn- type->string [type->id fx-type]
4+
(str (or (type->id fx-type) fx-type)))
55

6-
(defn- re-throw-with-stack [^Throwable ex stack]
6+
(defn- re-throw-with-stack [type->id ^Throwable ex stack]
77
(if (::cause (ex-data ex))
88
(throw ex)
99
(throw (doto (ex-info
1010
(str (ex-message ex)
1111
"\n\nCljfx component stack:\n "
12-
(->> stack (map type->string) (str/join "\n "))
12+
(->> stack
13+
(map #(type->string type->id %))
14+
(str/join "\n "))
1315
"\n")
1416
(with-meta {::cause ex} {:type ::hidden}))
1517
(.setStackTrace (.getStackTrace ex))))))
@@ -62,7 +64,7 @@
6264
(binding [*type->lifecycle* type->lifecycle
6365
*type->id* type->id]
6466
(when-let [explain-data (s/explain-data :cljfx/desc (assoc desc :fx/type fx-type))]
65-
(throw (ex-info (str "Invalid cljfx description of " (type->string fx-type) " type:\n"
67+
(throw (ex-info (str "Invalid cljfx description of " (type->string type->id fx-type) " type:\n"
6668
(explain-str explain-data))
6769
explain-data)))))
6870

@@ -75,17 +77,24 @@
7577
(try
7678
(ensure-valid-desc desc fx-type type->lifecycle type->id)
7779
(lifecycle/create lifecycle desc opts)
78-
(catch Exception ex (re-throw-with-stack ex stack)))))
80+
(catch Exception ex (re-throw-with-stack type->id ex stack)))))
7981
(advance [_ component desc opts]
8082
(let [stack (conj (::stack opts) fx-type)
8183
opts (assoc opts ::stack stack)]
8284
(try
8385
(ensure-valid-desc desc fx-type type->lifecycle type->id)
8486
(lifecycle/advance lifecycle component desc opts)
85-
(catch Exception ex (re-throw-with-stack ex stack)))))
87+
(catch Exception ex (re-throw-with-stack type->id ex stack)))))
8688
(delete [_ component opts]
8789
(let [stack (conj (::stack opts) fx-type)
8890
opts (assoc opts ::stack stack)]
8991
(try
9092
(lifecycle/delete lifecycle component opts)
91-
(catch Exception ex (re-throw-with-stack ex stack))))))))
93+
(catch Exception ex (re-throw-with-stack type->id ex stack))))))))
94+
95+
;; Ensure there is state at top level
96+
;; When root node is found, add listener (F12 by default) to open UI
97+
;; Should be configurable if open by default or wait for root node to add listener (default)
98+
;; inspector view:
99+
;; 1. show tree of components
100+
;; 2. for components, try to show props. by looking up something like :child* :props?

0 commit comments

Comments
 (0)