Fork me on GitHub
#portal
<
2021-05-04
>
plexus08:05:03

A small thing I noticed, when evaluating portal/open

Multiple methods in multimethod 'simple-dispatch' match dispatch value: class portal.runtime.jvm.client.Portal -> interface clojure.lang.IDeref and interface clojure.lang.IPersistentMap, and neither is preferred

djblue03:05:48

I think I can use a prefer-method but haven't gotten to it yet 😅

djblue03:05:50

I still don't understand why my https://github.com/djblue/portal/blob/master/src/portal/runtime/jvm/client.clj#L76-L77 method isn't preferred :thinking_face:, any ideas?

djblue03:05:30

The main feature this supports is deref-ing the result of open to get the current selected value back into your runtime repl environment

plexus06:05:33

yeah, I like that, also being able to swap/reset is nice

plexus06:05:14

I'm starting to add this to my user / cljs.user namespaces

(def portal-instance nil)

(defn portal
  "Open a Portal window and register a tap handler for it. The result can be
  treated like an atom."
  []
  (let [p (portal/open portal-instance)]
    (set! portal-instance p)
    (add-tap #'portal/submit)
    p))

plexus06:05:16

the clj version

(def portal-instance (atom nil))

(defn portal
  "Open a Portal window and register a tap handler for it. The result can be
  treated like an atom."
  []
  (let [p ((jit portal.api/open) @portal-instance)]
    (reset! portal-instance p)
    (add-tap (jit portal.api/submit))
    p))
(using the [jit macro](https://lambdaisland.com/blog/2019-12-11-advent-of-parens-11-integrant-in-practice))

plexus06:05:55

so I can start with (user/portal), or get results back out with @(user/portal)

plexus08:05:27

@U1G869VNV I had a better look, this is coming from clojure.pprint/simple-dispatch, not from print-method...

plexus08:05:07

you might be interested in https://github.com/lambdaisland/data-printers , even if only for inspiration. There are multiple print implementations across clj/cljs to reckon with

👍 2
plexus08:05:05

BTW loving that I can do this

(tap> (bean clojure.pprint/simple-dispatch))

💯 2
djblue17:05:24

You can all call bean on any object from the command palette 👌

🚀 3
djblue17:05:46

Just in case you already tap the value out without calling bean on it