|
319 | 319 |
|
320 | 320 | (load "dev/validation")
|
321 | 321 |
|
322 |
| -(defn wrap-validating-type->lifecycle |
| 322 | +(defn wrap-type->lifecycle |
323 | 323 | "Wrap type->lifecycle used in the cljfx UI app with improved error messages
|
324 | 324 |
|
325 | 325 | Wrapped lifecycle performs spec validation of cljfx descriptions that results
|
|
328 | 328 | Additionally, exceptions thrown during cljfx lifecycle show a cljfx component
|
329 | 329 | stack to help with debugging.
|
330 | 330 |
|
331 |
| - Args: |
| 331 | + Optional kv-args: |
332 | 332 | type->lifecycle the type->lifecycle fn used in opts of your app
|
333 | 333 | type->id custom type->id if you need a way to get id from your
|
334 | 334 | custom lifecycles"
|
335 |
| - ([type->lifecycle] |
336 |
| - (wrap-validating-type->lifecycle type->lifecycle *type->id*)) |
337 |
| - ([type->lifecycle type->id] |
338 |
| - (let [f (memoize wrap-lifecycle)] |
339 |
| - (fn [type] |
340 |
| - (f type type->lifecycle type->id))))) |
341 |
| - |
342 |
| -(def validating-type->lifecycle |
| 335 | + [& {:keys [type->lifecycle type->id] |
| 336 | + :or {type->lifecycle *type->lifecycle* |
| 337 | + type->id *type->id*}}] |
| 338 | + (let [f (memoize wrap-lifecycle)] |
| 339 | + (fn [type] |
| 340 | + (f type type->lifecycle type->id)))) |
| 341 | + |
| 342 | +(def type->lifecycle |
343 | 343 | "Default type->lifecycle that can be used in the cljfx UI app to improve error
|
344 | 344 | messages"
|
345 |
| - (wrap-validating-type->lifecycle (some-fn fx/keyword->lifecycle fx/fn->lifecycle))) |
| 345 | + (wrap-type->lifecycle)) |
346 | 346 |
|
347 | 347 | (defn explain-desc
|
348 | 348 | "Validate cljfx description and report any issues
|
|
351 | 351 | type->lifecycle the type->lifecycle fn used in opts of your app
|
352 | 352 | type->id custom type->id if you need a way to get id from your
|
353 | 353 | custom lifecycles"
|
354 |
| - ([desc] |
355 |
| - (explain-desc desc *type->lifecycle* *type->id*)) |
356 |
| - ([desc type->lifecycle] |
357 |
| - (explain-desc desc type->lifecycle *type->id*)) |
358 |
| - ([desc type->lifecycle type->id] |
359 |
| - (binding [*type->lifecycle* type->lifecycle |
360 |
| - *type->id* type->id] |
361 |
| - (if-let [explain-data (s/explain-data :cljfx/desc desc)] |
362 |
| - (println (explain-str explain-data)) |
363 |
| - (println "Success!"))))) |
| 354 | + [desc & {:keys [type->lifecycle type->id] |
| 355 | + :or {type->lifecycle *type->lifecycle* |
| 356 | + type->id *type->id*}}] |
| 357 | + (binding [*type->lifecycle* type->lifecycle |
| 358 | + *type->id* type->id] |
| 359 | + (if-let [explain-data (s/explain-data :cljfx/desc desc)] |
| 360 | + (println (explain-str explain-data)) |
| 361 | + (println "Success!")))) |
364 | 362 |
|
365 | 363 | ;; stretch goals
|
366 | 364 | ;; - ui reference for searching the props/types/etc
|
|
0 commit comments