Fork me on GitHub
#portal
<
2023-12-26
>
Dieter Van Eessen07:12:43

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

Dieter Van Eessen08:12:53

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

djblue22:12:42

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?

Dieter Van Eessen19:12:38

yep, that's it. Darn... could've found this if I had been digging some more. My apology for wasting your time :S

djblue02:12:24

No worries, finding things isn't always easy. Let me know if you run into any more issues 👌