dirac 2016-11-14

@darwin can you give me some pointers on how to return a hiccup representation from cljs-devtools, given a data structure?

I'm not quite sure where to get started

the library installs a custom formatter which produces JsonML, not hiccup

Ohhhhh

I internally use hiccup, but convert it at some point to JsonML

And the Chrome devtools renders JsonML

Is there a way to get at the hiccup before it's converted?

I've read that document

I'm just not quite sure what the function entry point is

I can see all the pieces, but I'm not sure what I would call to put it all together?

it is probably not as simple as calling just one function to get whole representation

call header-api-call to get header JsonML for given value

that header might contain "object references” which you might want to embed inline and call header-api-call on them

also you might want to ask if given value has “body” part by calling has-body-api-call

and if it has, you can get body JsonML by calling body-api-call

devtools renders bodies as expandable content via disclosure triangles

Will it work to do this in an application that is currently using devtools?

I’m not aware of any global state which would interfere with calls from custom formatter

btw. why don’t you use window.devtoolsFormatters directly? you would render all formatters potentially installed

how would I use that?

read that google doc

everything is documented there

btw. don’t forget to properly pass configObject down when inlining or expanding, cljs-devtools rely on it (there we store our “continuation” state)

Where does configObject come from?

search the google doc, you might get it when following object references

object references are kind of continuations, at those points you might decide to render them inline or wait for some user action and render them later, or never, or always, it is up to you, but config might hold some state needed for continuation