This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-26
Channels
- # announcements (4)
- # babashka (5)
- # beginners (11)
- # clj-kondo (4)
- # clojure-bay-area (1)
- # clojure-dev (8)
- # clojure-europe (4)
- # clojure-norway (10)
- # conjure (2)
- # datomic (12)
- # emacs (3)
- # hyperfiddle (5)
- # jobs-discuss (26)
- # lsp (55)
- # observability (3)
- # overtone (1)
- # portal (5)
- # practicalli (1)
- # sql (11)
- # xtdb (8)
Hello, how can I get a value back in the repl which has been send (and is selected) to a remote portal server? Having a serverA at port 3000, then in cljs-repl (portal.client.web/submit {:port 3000} "Hello world"). This value is tapped to 'clientA'. From a clj-repl, I can (deref <portalSession>), returning the value selected in clientA. From the cljs-repl there is no <portalSession>. When doing (def p (portal.web/open {:port 3000})), a new window (client B, with title 'portal client') pops up. I assume this is a new portal serverB running in browser. (deref p) now returns value that was selected in this window (clientB), not the window (clientA). kind regards, Dieter
Can I get access to this selected value in clientA from javascript? Some context: -Compiled the portal cljs code with (weasel.repl/connect ...) inside portal.ui.core -Using this main.js, started a server with portal.runtime.jvm.server/handler on port 3000 -Connecting to weasel repl with (cider.piggieback/cljs-repl (weasel/repl-env)) -tapping values to it with portal.client.web/submit :port 3000.... Now playing with the DOM, experimenting with hoplon to make rendered hiccup code interactive. I can retrieve a value tapped from clojure repl by (deref p) and from clojurescript repl by navigating the DOM ((.getElementsByClassName ) or (.getElementsById), depending on which viewer you've selected.) But I wonder which javascript objects are created by portal which I can use to find selected elements... kind regards, Dieter
If you are compiling a version of the UI and have access to the in memory state, you can use https://github.com/djblue/portal/blob/master/src/portal/ui/state.cljs#L51-L57 to get access to the selected value. Is that what you are looking for?
yep, that's it. Darn... could've found this if I had been digging some more. My apology for wasting your time :S