r/Clojure • • Oct 24 '19

Introducing shadow-cljs Inspect

https://clojureverse.org/t/introducing-shadow-cljs-inspect/5012
69 Upvotes

9 comments sorted by

View all comments

10

u/danielneal2 Oct 24 '19 edited Oct 24 '19

Just want to say thanks for making this - as a mainly ClojureScript / React Native dev at the moment, I'd been eyeing REBL with envy, as I go around accidentally printing my re-frame db to the console, struggling to navigate complex nested datastructures, sticking printlns everywhere. This worked straight away when I tried it - just added the :preload in to my shadow-cljs.edn and there it was on localhost:9630. Navigating the full re-frame database worked super fast thanks to the lazy/minimal approach to sending info of the wire. A giant leap forward for debugging cljs apps, and a great job!

1

u/CapableWeb Oct 26 '19

Not sure how helpful this will be, but I'm developing a ClojureScript application where the app-db tends to be a huge monster to inspect as well.

What I ended up doing, was implementing my own inspect view that can be enabled by either setting a value in localStorage or by keyboard shortcuts (entering the Konami code anywhere). Once enabled, the Inspect view is a drawer that covers 30% of the screen by default but when hovering, covers the full screen. In the inspect view, I print out the app-db with (-> cljs.pprint/pprint with-out-str) + a selector that can be inputted in a text input. Also adding a button to copy/paste the currently selected slice of the state from/into the app-db.

While it's great to be able to have shadow-cljs inspect available on a different port while in dev, I've found it super helpful in understanding bugs related to the state in production, as we ship the application with our custom inspect view still available in production.