portal

https://github.com/djblue/portal
djblue 2021-05-05T03:05:48.027900Z

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

djblue 2021-05-05T03:09:50.028100Z

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?

djblue 2021-05-05T03:11:30.028400Z

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

djblue 2021-05-05T03:12:13.028600Z

https://github.com/djblue/portal#portal-atom

plexus 2021-05-05T06:32:33.028900Z

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

plexus 2021-05-05T06:33:14.029100Z

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))

plexus 2021-05-05T06:34:16.029300Z

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))

plexus 2021-05-05T06:34:55.029500Z

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