How to check objects?

I am following the om textbook. I use Light Table to configure an external browser connection. Also, in my clojurescript code, I call (enable-console-print!) To send my println statements to the browser console.

The problem is that when I print the om component, something like:

(println (om/build my-component-function my-data))

The output I get is:

#<[object Object]>

I have the same problem if I just eval (om/build my-component-function my-data) in LightTable.

The ability to check this object will be useful for debugging. How can I print something more meaningful?

+7
om clojurescript
source share
3 answers

1 Try using (.log js/console object) , which is equivalent to ClojureScript console.log(object);

2 You can also install Extend developer tools for Google Chrome , which allows you to view the React / Om components that you have on the page

+10
source share

As you can read in the README file of the Om project https://github.com/swannodette/om

You can use ankha , an EDN Inspector submission. Then you can print your component as edn and go to anka. Another solution might be (.dir js/console object) and you can test your component on Firebug or Chrome console

+3
source share

Try cljs-devtools . This library uses "custom formats" to create clojure print structures in the Chrome Javascript Console.

When you include custom formatting and integrate the library into your project, this should pretty print your object:

 (.log js/console your_namespace.your_object) 

Also enter the command in the console (with code completion)

 your_namespace.your_object 

Disclaimer: This feature is experimental in Chrome Dev Tools, and I am the author of the library.

+2
source share

All Articles