Fork me on GitHub
#reveal
<
2020-10-26
>
seancorfield17:10:45

@vlaaad Something changed between 1.0.130 and 1.0.137 that now causes a stack overflow exception when evaluating that auto-table view code

java.lang.StackOverflowError: nil
in clojure.lang.RT.get (RT.java:761)
in clojure.core/fn--6114/fn--6115 (core.clj:3666)
in clojure.lang.MultiFn.invoke (MultiFn.java:233)
in clojure.core/pr-on (core.clj:3676)
in clojure.core/pr-on (core.clj:3670)
in clojure.core/print-prefix-map/fn--7343 (core_print.clj:233)
in clojure.core/print-sequential (core_print.clj:61)
in clojure.core/print-prefix-map (core_print.clj:229)
in clojure.core/print-map (core_print.clj:238)
in clojure.core/fn--7372 (core_print.clj:266)
in clojure.core/fn--7372 (core_print.clj:263)
in clojure.lang.MultiFn.invoke (MultiFn.java:234)
in clojure.core/pr-on (core.clj:3676)
in clojure.core/pr-on (core.clj:3670)
in clojure.core/print-prefix-map/fn--7343 (core_print.clj:233)
...

vlaaad17:10:12

Hmm, I checked it (https://github.com/vlaaad/reveal/blob/master/examples/e04_tap_to_table.clj) before releasing 1.0.137, and that worked fine for me, can you share a repro?

seancorfield17:10:53

(let [last-tap (atom nil)]
    (add-tap #(reset! last-tap %))
    (rx/view-as-is
      {:fx/type rx/observable-view
       :ref last-tap
       :fn (fn [x]
             {:fx/type :v-box
              :children
              [{:fx/type rx/value-view
                :v-box/vgrow :always
                :value (assoc (meta x) :_obj x :_class (class x))}
               (if (or (nil? x) (string? x) (not (seqable? x)))
                 {:fx/type rx/table-view
                  :items [x]
                  :v-box/vgrow :always
                  :columns [{:fn identity :header 'value}]}
                 (let [head (first x)]
                   {:fx/type rx/table-view
                    :items x
                    :v-box/vgrow :always
                    :columns (cond
                              (map? head) (for [k (keys head)] {:header k :fn #(get % k)})
                              (map-entry? head) [{:header 'key :fn key} {:header 'val :fn val}]
                              (indexed? head) (for [i (range (count head))] {:header i :fn #(nth % i)})
                              :else [{:header 'item :fn identity}])}))]})}))

seancorfield17:10:08

I added the extra v-box for metadata and value.

vlaaad18:10:22

Hmm, still works fine... Could it be that you tap> that form?

vlaaad18:10:25

or maybe you do something like tap> and then print it?

vlaaad18:10:51

rx/view-as-is is identity since 1.0.137, and that means it will print the contents of the atom, that might cause issues if you tap that atom

vlaaad18:10:38

Can you try this maybe?

(let [last-tap (atom nil)]
  (add-tap #(reset! last-tap %))
  (rx/stream-as-is
    (rx/as
      {:fx/type rx/observable-view
       :ref last-tap
       :fn (fn [x]
             {:fx/type :v-box
              :children
              [{:fx/type rx/value-view
                :v-box/vgrow :always
                :value (assoc (meta x) :_obj x :_class (class x))}
               (if (or (nil? x) (string? x) (not (seqable? x)))
                 {:fx/type rx/table-view
                  :items [x]
                  :v-box/vgrow :always
                  :columns [{:fn identity :header 'value}]}
                 (let [head (first x)]
                   {:fx/type rx/table-view
                    :items x
                    :v-box/vgrow :always
                    :columns (cond
                               (map? head) (for [k (keys head)] {:header k :fn #(get % k)})
                               (map-entry? head) [{:header 'key :fn key} {:header 'val :fn val}]
                               (indexed? head) (for [i (range (count head))] {:header i :fn #(nth % i)})
                               :else [{:header 'item :fn identity}])}))]})}
      (rx/raw-string "tap-to-table-view" {:fill :object}))))

seancorfield18:10:23

That doesn't render anything that can be right-click -> view'd

seancorfield18:10:34

I'm not seeing how to make that render a view...

vlaaad18:10:23

it should render "tap-to-table-view" text

seancorfield19:10:46

Ah, I was still using 1.0.130 and that wasn't viewable but in 1.0.137 it is!

vlaaad19:10:26

ah yes, 1.0.137!

seancorfield19:10:01

Switched back to 1.0.137 and that seems to work as expected now. Thanks @vlaaad!

vlaaad19:10:48

haven't thought making view-as-is an identity would break anything...

vlaaad19:10:18

(it's deprecated, 1.0.137 allows viewing cljfx descriptions directly)

3
seancorfield19:10:13

I'm going to be doing some RDD talks to a couple of online Clojure groups so Reveal will be featured there 🙂

seancorfield19:10:12

I'll show building a small web app in the REPL and one of the things I'll show is browsing the app in Reveal side-by-side with my editor.

seancorfield19:10:52

I browse online docs that way too, using Reveal...

vlaaad20:10:58

very curious to see it

vlaaad20:10:53

Please ping me when the tasks will go live!

seancorfield20:10:25

Sure. The date/time will get posted to #events once they are scheduled and I'll probably post links to the recording here for Reveal users 🙂

👍 6