portal

chromalchemy 2024-08-12T15:09:09.449989Z

I’m trying to just see the results of evaluating a collection without the dual metadata panes. (limited real estate on laptop)

chromalchemy 2024-08-13T16:46:27.706849Z

Ok thanks. I thought portal.viewer/edn was the inspector view. No longer getting the error!

chromalchemy 2024-08-13T16:55:43.267129Z

I think i often prefer vertical display of the inspector, and it is easier to select individual values and keywords, compared to pprint viewer. This is what I have now to show at least the first few maps in a collection (of maps) In my helper code:

(do
    (p/clear)
    (->> [{:a 2 :b 1} {:a 2 :c 2} {:d 3}]
      (v/inspector)
      (tap>))
    (call-ui ;; with timeout
      #(do
         (command :select-child)
         (command :select-child)
         (command :select-child)
         (command :expand-inc)
         (command :select-next)
         (command :expand-inc)
         (command :select-parent)
        )))
The select-parent is to put focus on the overall collection, for no-fuss filtering. I tried adding a focus-selected somewhere in the script. If i do it early, then I can’t seem to select-child after. If i do it at the end, then the newly focused view seems to forget the previously expanded state of the first few children.. So in effect, I’m still not able to hide the outer meta container and show the expanded results of the collection contents simultaneously. Also, is there a command to expand all the contents of a collection? Rather than crawling through it with expand-inc + navigation?

chromalchemy 2024-08-13T17:22:38.651759Z

With more sugar:

(do
    (->> [{:a 2 :b 1} {:a 2 :c 2} {:d 3}]
      (clear-inspector-tap>))
    (pui ;; with timeout
      #(do
        (expand-first)
        (expand-next)
        (command :select-parent)))
using this for repeated calls:
(defn repeat-command [n ui-command-fn]
  (dotimes [i n] (ui-command-fn)))
I was complaining about convoluted structure and verbosity. But some functional composition goes a long way!

chromalchemy 2024-08-12T15:09:59.473329Z

chromalchemy 2024-08-12T15:10:27.882509Z

I rarely need the outer metadata. Just want to see the results data concisely (with the option to filter, and not have longer results cut off like normal pprint results)

chromalchemy 2024-08-12T15:11:57.248559Z

I understand I can drive the view by sending is cljs. But this is convoluting my eval code. Is there more reliable an/or succint way to do it than this?

(do 
  (->> [{:a 1} {:a 2} {:a 3}]
    (v/edn)
    (tap>))
  (timeout 500 
    #(do 
       (p/eval-str "(portal.ui.commands/select-child portal.ui.state/state)")
       (p/eval-str "(portal.ui.commands/select-child portal.ui.state/state)")
       (p/eval-str "(portal.ui.commands/focus-selected portal.ui.state/state)")))
  )
I have wrapped this in helper fns to make calls smaller. But still feels like less than ideal ergonomics?

chromalchemy 2024-08-12T15:12:38.697209Z

Also, this is currently giving me an error on the focus command:

chromalchemy 2024-08-12T15:13:58.848729Z

If I focus the collection with the mouse, and run the focus-selection command from the panel palette, it works. But running it from code feels temperamental (dont love the timeout either)

djblue 2024-08-12T20:45:06.804189Z

I think you want portal.viewer/pprint ("View value printed via clojure.pprint/pprint.") here not portal.viewer/edn ( "Parse a string as EDN. Will render error if parsing fails.").

djblue 2024-08-12T20:47:12.964639Z

If you setup a custom tap list, you can tag that list with portal.viewer/pprint , then every value you tap will be pretty printed instead of using the default inspector.