Fork me on GitHub
#clerk
<
2023-08-13
>
teodorlu12:08:52

Hi! I just ran into this error message:

Clerk can only sync values which can be round-tripped in EDN.
Has anyone written a function to strip values that can’t be round-tripped? Does Clerk provide something?

2
teodorlu12:08:46

Right now I do this:

^{::clerk/sync true}
(defonce last-tapped (atom nil))

(comment
  (tap> (rand))
  @last-tapped

  )

(defn store-tapped [val]
  (reset! last-tapped (with-out-str (pprint val))))

(add-tap #'store-tapped)

{:nextjournal.clerk/visibility {:code :show :result :show}}
@last-tapped
But it’s not ideal because I can’t use Clerk’s object browser on the tapped values (incoming http requests in my case).

mkvlr15:08:17

not a direct answer but maybe you can avoid using a sync atom for this use case?

2
mkvlr15:08:19

You could look at clerks built-in tap inspector for reference. Also curious what made you write your own.

👀 2
teodorlu16:08:55

> not a direct answer but maybe you can avoid using a sync atom for this use case? Originally, I had trouble getting the web browser showing Clerk to update immediately. Though I can’t reproduce the issue now. I’ve also upgraded from {:mvn/version "0.13.842"} to {:mvn/version "0.14.919"} since. Deleted ::clerk/watch true now, thanks! Not sure how to use the tap viewer. I found https://github.com/nextjournal/clerk/tree/90ec95dadc48a6d53e1156fc7e4fb2b6959f1c9b/src/nextjournal/clerk/tap.clj, but I’m not sure what to do. Are there docs for it somewhere? I can’t find it mentioned in the book.

teodorlu16:08:53

> Not sure how to use the tap viewer. I found https://github.com/nextjournal/clerk/tree/90ec95dadc48a6d53e1156fc7e4fb2b6959f1c9b/src/nextjournal/clerk/tap.clj, but I’m not sure what to do. Are there docs for it somewhere? I can’t find it mentioned in the book. Found it:

(nextjournal.clerk/show! 'nextjournal.clerk.tap)
https://github.com/nextjournal/clerk/blob/90ec95dadc48a6d53e1156fc7e4fb2b6959f1c9b/book.clj#L914-L926. Looks like this hasn’t been pushed to book.clerk.vision yet.

teodorlu16:08:59

The tap inspector is really nice 😊

teodorlu16:08:48

A thought about the tap viewer: When tap>-ing request maps, I find myself expanding the view and asking for 8 more… values every time. If I had buttons for “always expand tap object browser” and “increase object browser budget”, I’d click them. Right now, my http tap> worflow is something like: 1. refresh web browser previewing the html I’m making 2. press > button to expand view in clerk 3. click 8 more… 4. clerk tap> object browser collapses 5. i press > again 6. … then I can see the full value. I’d prefer less steps!

mkvlr17:08:18

ah good catch, will update the book when I’m back at the computer

👍 2
mkvlr17:08:02

and for your other points: not remembering the expansion state is a bug, issue welcome

👍 2
mkvlr17:08:34

you could also turn off elisions for maps, either globally or for the tap inspector ns only. Let me know if you need help here and I can come up with a snippet later

mkvlr17:08:26

there’s also the auto-expand-results? option but I’m not sure right now if it can be set for the tap inspector already. Also something we’d want to fix if not.

teodorlu17:08:36

> you could also turn off elisions for maps, either globally or for the tap inspector ns only. Let me know if you need help here and I can come up with a snippet later Is that with ::clerk/budget nil? I’ve set it to nil, but I still get some s, see attached image. If I’m doing it wrong, I’d love a snippet!

teodorlu17:08:25

> and for your other points: not remembering the expansion state is a bug, issue welcome I’ll make an issue 👍 Issue: https://github.com/nextjournal/clerk/issues/543

mkvlr18:08:26

not budget (that’s the global limit) but page-size on the map viewer, the book should have examples there under elisions

👍 2
teodorlu18:08:03

Gotcha. Finally got leverage out of viewers just being data! 😄

^{::clerk/budget nil ::clerk/auto-expand-results? true}
(clerk/with-viewer (update nextjournal.clerk.viewer/map-viewer
                           :page-size (partial * 10))
  @latest-tap)

🙌 4