Fork me on GitHub
#portal
<
2021-10-19
>
wilkerlucio21:10:33

hello folks, how can I run an arbitrary command over a value on portal?

djblue21:10:58

Yes. You have two options, get the value back in the repl with the portal atom or use the new portal.api/register! to register a var as a command with portal.

wilkerlucio21:10:58

hello Chris! long time, we need to get more beers in a vault again 🙂

💯 3
wilkerlucio21:10:04

hey, not sure if I get how to do that

wilkerlucio21:10:47

what I would like is to highlight a value in the UI, and run a command (from Portal itself if possible) get a result

wilkerlucio21:10:29

maybe, in the command pallet, being able to run things like: (slurp *v), being *v the selected value on the UI, makes sense?

djblue21:10:45

slurp should already be available if the value is slurpable 👌

djblue21:10:40

I also added https://github.com/djblue/portal#commands which might be a useful read 👌

wilkerlucio21:10:28

gotcha, that's nice, altough I still think would be cool to have the option to run arbitrary code on the selected value, is that something you consider to add support for?

seancorfield21:10:52

(it's something Reveal supports, just FYI)

wilkerlucio21:10:31

yeah, that's what Im getting the inspiration from, there the selected value is bound to *v, so we can do these arbitrary runs

seancorfield21:10:37

I have not missed that functionality since switching to Portal -- but both Reveal and REBL had something equivalent.

seancorfield21:10:36

I do, however, have Portal setup as an atom (as dev/portal) so if I really need to run arbitrary code on a selected value, I can do it via my editor in an RCF with (some-fn @dev/portal)

seancorfield21:10:52

(but I haven't needed to do that, expect to test it works 🙂 )

wilkerlucio21:10:41

cool, I just tried to do that atom setup, does this look right?

(do
  (require 'portal.api)
  (def user/portal (portal.api/open))
  (add-tap #'portal.api/submit))

wilkerlucio21:10:54

when I look that up I see:

user/portal
=> {:session-id #uuid"43472179-f905-4cf1-9f22-a67a184a7cfd"}

djblue21:10:10

(deref user/portal)

wilkerlucio21:10:12

which doesn't seem to be an atom, is it a differnet open fn?

djblue21:10:30

It implements the interface/protocol 👌

wilkerlucio21:10:39

strange, its coming nil here

djblue21:10:52

Do you have anything selected in the UI?

wilkerlucio21:10:00

let me try that

wilkerlucio21:10:19

nice!! gotcha 😄

wilkerlucio21:10:30

yeah, that works 🙂

awesome 1
seancorfield21:10:10

It's a pretty cool feature 🙂

pez06:10:27

Some inspo if it ever is a candidate for inclusion, is from shadow-cljs’ inspector. There’s a small REPL prompt/area where $o is bound to the currently inspected object.

djblue15:10:32

My main reluctance to adding a repl window is doing it will would be a lot of work and it would still fall short of the customized experience each user has within their editor.

1
👍 1
pez15:10:02

Yeah, I think it makes sense to encourage using the atom.