This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-23
Channels
- # announcements (2)
- # architecture (83)
- # asami (2)
- # babashka (49)
- # bangalore-clj (2)
- # beginners (235)
- # braveandtrue (1)
- # calva (17)
- # clojure (109)
- # clojure-australia (5)
- # clojure-czech (5)
- # clojure-dev (24)
- # clojure-europe (17)
- # clojure-germany (2)
- # clojure-nl (3)
- # clojure-serbia (13)
- # clojure-spain (1)
- # clojure-spec (1)
- # clojure-uk (20)
- # clojurescript (3)
- # community-development (34)
- # conjure (10)
- # cursive (21)
- # data-science (1)
- # datahike (1)
- # datalog (1)
- # datomic (12)
- # etaoin (3)
- # events (2)
- # fulcro (13)
- # graphql (8)
- # heroku (2)
- # lsp (58)
- # malli (32)
- # membrane (24)
- # off-topic (63)
- # parinfer (2)
- # pathom (14)
- # portal (14)
- # re-frame (16)
- # reagent (50)
- # releases (1)
- # rum (1)
- # shadow-cljs (10)
- # sql (6)
- # startup-in-a-month (1)
- # timbre (2)
- # tools-deps (61)
- # xtdb (4)
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
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 😬
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.
You can try version 0.6.4
(before I removed the auto-datafy) and see if everything works the way you expect
https://github.com/djblue/portal/blob/master/examples/node/dev/user.cljs#L17-L19 is a node example
(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))
☝️ worked for me when I explicitly called clojure.datafy/datafy
on the point via the command palette
@U07FP7QJ0 were you able to get it working?
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?
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.
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.