portal

https://github.com/djblue/portal
plexus 2021-03-23T07:09:45.008700Z

when using portal to inspect clojurescript values, does it honor datafy/nav? I tried implementing the protocols for my types (third party JS types) but it doesn't seem to be picking it up

djblue 2021-03-25T02:06:08.011500Z

@plexus were you able to get it working?

plexus 2021-03-29T07:40:53.014Z

Tried it now, indeed hitting the >_ button and putting in clojure.datafy/datafy did the trick. Is that button documented somewhere? Are there plans to make it detect datafiable objects directly?

djblue 2021-03-29T14:31:43.014800Z

The button is a new add so it's not documented yet, I'm thinking of putting together a tutorial page. What behavior would you expect of portal if you implemented datafy for your object? I've experimented a little and haven't found anything I've liked.

plexus 2021-03-30T07:10:09.016100Z

I think ideally it would show it as the datafied value, and automatically invokes nav to drill down. I think that's what REBL does? The only downside to that I think is that it obscures the actual type, but maybe it can show a hint of the type. More advanced would be to allow toggling between the printed representation, and the datafied value. If I really had a magic wand I'd love to see a convention in the community for communicating the reader tag that should be associated with a certain datafied value. So in the above example, datafy could return something like ^{:reader-tag 'pixi/Point} {:x 10 :y 10}, and Portal would be able to render it as #pixi/Point {:x 10 :y 10}, but with colors and the ability to drill down.

1
djblue 2021-03-23T07:28:17.008800Z

Nav should work automatically when you double click a value. Portal use to automatically datafy values when you nav-ed to them, however I removed this behavior instead for an explicit datafy call. The reason was that it made it harder if datafy was implemented for an object, but wasn't the desired behavior. Like I wanted to just slurp a file, or deref an atom. You can (cmd|ctrl) + shift + p or click the bottom right to open the command palette and call datafy explicitly for now 😬

djblue 2021-03-23T07:35:28.009100Z

I could add it back now that portal has the concept of focusing a value, which is independent of both datafy and nav, which should solve the issues I had with the previous behavior.

djblue 2021-03-23T07:36:27.009300Z

You can try version 0.6.4 (before I removed the auto-datafy) and see if everything works the way you expect

plexus 2021-03-23T08:24:06.009800Z

that doesn't seem to be what I'm seeing

plexus 2021-03-23T08:24:31.010Z

plexus 2021-03-23T08:24:43.010800Z

maybe it's because I'm also implementing IPrintWithWriter?

djblue 2021-03-23T16:40:22.011Z

(deftype Point [x y]
  Datafiable
  (datafy [p] {:x (.-x p) :y (.-y p)})
  IPrintWithWriter
  (-pr-writer [this writer _]
    (write-all writer (pr-str (datafy this)))))

(tap> (Point. 1 2))

djblue 2021-03-23T16:41:19.011300Z

☝️ worked for me when I explicitly called clojure.datafy/datafy on the point via the command palette