Is there a way to save runtime values in clojurescript, to inspect them at the repl ?
I do this by adding a def inside the function I am debugging:
(defn my-fn [x y]
(def _args [x y])
....)
(comment
_args => [1 2]
)So I first add a def with what I want to inspect and then add a comment block below that and then eval the def. I always start these names with a underscore to make sure I don't define stuff that is used in functions
cool trick, quite simple, thanks.
for debugging there is also http://www.flow-storm.org/ and https://github.com/flow-storm/cider-storm which allows to define any value (or all of them) to work with them at the repl and much more
one problem with using def like that is if my-fn is called multiple times as part of the execution you will only get the last one. Same if you need to capture things inside any kind of "looping", like map, filter, etc
And totally agree for more powerfull stuff look at flowstorm
I also use inline defs a lot, but another cool trick is to console.log something and then in console right click on the logged object and click Store as Global Variable. Then you can access it in the REPL with js/temp0
And if you need something more advanced there's https://github.com/AbhinavOmprakash/snitch But as far as I know the latest version doesn't work with ClojureScript so you need to use an older one