This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-11
Channels
- # asami (19)
- # babashka (41)
- # beginners (115)
- # biff (7)
- # calva (78)
- # clj-kondo (29)
- # cljs-dev (9)
- # clojure (39)
- # clojure-europe (17)
- # clojure-gamedev (29)
- # clojure-nl (1)
- # clojure-norway (9)
- # clojure-spec (2)
- # clojure-uk (3)
- # clojurescript (7)
- # core-async (26)
- # cursive (16)
- # datomic (13)
- # emacs (1)
- # events (5)
- # fulcro (2)
- # funcool (4)
- # gratitude (1)
- # helix (1)
- # holy-lambda (1)
- # humbleui (1)
- # introduce-yourself (4)
- # java (1)
- # jobs (2)
- # jobs-discuss (9)
- # lsp (28)
- # matcher-combinators (2)
- # mathematics (1)
- # membrane (1)
- # nbb (12)
- # off-topic (10)
- # pathom (52)
- # polylith (38)
- # portal (32)
- # re-frame (4)
- # reagent (16)
- # reitit (2)
- # remote-jobs (1)
- # reveal (1)
- # rewrite-clj (10)
- # sci (67)
- # shadow-cljs (45)
- # squint (1)
- # tools-build (13)
- # tools-deps (16)
@djblue hello, Im seeing some stack overflow errors when I try to log some maps to portal in the latest version
I used to print those same structures without issues before, so I believe its something about the new version
(this is a quite large map)
the root is a regular map, but nested inside it has other custom types
also volatiles and atoms
Mind trying https://github.com/djblue/portal/commit/b9de7ff4b53bac0ccbed753d209ce1aa9608dfc0 locally with the same data?
Instead of lazily pr-str'ing objects, which was causing other issues, I do it up front. I remembered to exclude atoms, but forgot about volatiles. Those tend to not print well, especially because they can have cycles. This is my best guess :thinking_face:
Should also be able to eval 👇 locally at the repl to try the fix
(in-ns 'portal.runtime)
(defn- to-object [buffer value tag rep]
(if-not *session*
(cson/tag buffer "remote" (pr-str value))
(let [m (meta value)]
(when (atom? value) (watch-atom value))
(cson/tag
buffer
"object"
(cond-> {:tag tag
:id (value->id value)
:type (pr-str (type value))
:protocols (cond-> #{}
(deref? value) (conj :IDeref))}
m (assoc :meta m)
rep (assoc :rep rep)
(not (deref? value))
(assoc :pr-str (pr-str value)))))))
I can confirm it fixes after I run the patch in my REPL 🙂
Is portal compatible with shadow-cljs? I can't seem to get it working. My project runs in the browser, I have portal on my classpath, I use npx shadow-cljs watch :app
to boot up a repl, open the web page, but portal.web/open
throws Cannot set properties of null (setting 'onunload')
If you look in the devtools, it's probably complaining about popups. Might need to enable popups to get the UI open.
FYI https://cljdoc.org/d/djblue/portal/0.34.1/doc/guides/shadow-cljs is another way to run web taps
So would something like this allow me to tap values from the web page and display them in the Intellij plugin? :thinking_face:
Hm...I kind of got it working. I can tap values from my shadow cljs app, and they appear in intellij portal viewer, but now when I want to deref the selected portal value I have to do so from the clj repl? So values are getting serialized via transit from cljs to clj. Might be too much context switching to be worth it.
Seems only "pure data" values actually survive the trip as well, which the docs do mention.
The "in browser" setup is really cool tho. I put the portal setup code right in user.cljs
and preloaded it from shadow, so now it auto-pops open the portal window when I start my app. And @p
is easily accessible. Neat!!
Hey again! I think I may have found another bug: When implementing a custom nav
protocol it seems like the metadata specifying the default view is ignored. Also if Slack isn't the best place for this stuff please let me know if you'd rather I move it into GH.
Portal will try to set the default viewer on the metadata of a value based on what's selected in the UI https://github.com/djblue/portal/blob/master/src/portal/ui/commands.cljs#L504, but existing metadata takes precedence
Sure, I am doing something like this:
(tap>
(with-meta
{:foo 5}
{`clojure.core.protocols/nav
(fn [x _ _]
(with-meta
x
{:portal.viewer/default :portal.viewer/pr-str}))}))
I would expect that the metadata of value returned from nav
(in this case identity, but in my actual case, some derived data) would also work