reveal

Docs: https://vlaaad.github.io/reveal/ Source: https://github.com/vlaaad/reveal
seancorfield 2020-10-26T17:48:45.152600Z

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

vlaaad 2020-10-26T17:53:12.152800Z

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?

seancorfield 2020-10-26T17:56:53.153100Z

(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}])}))]})}))

seancorfield 2020-10-26T17:57:08.153300Z

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

vlaaad 2020-10-26T18:25:22.153500Z

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

vlaaad 2020-10-26T18:26:25.153700Z

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

vlaaad 2020-10-26T18:27:51.153900Z

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

vlaaad 2020-10-26T18:31:38.154100Z

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

seancorfield 2020-10-26T18:50:23.154300Z

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

seancorfield 2020-10-26T18:54:34.154500Z

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

vlaaad 2020-10-26T18:59:23.154700Z

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

vlaaad 2020-10-26T19:00:35.154900Z

seancorfield 2020-10-26T19:00:46.155300Z

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

vlaaad 2020-10-26T19:01:26.155500Z

ah yes, 1.0.137!

seancorfield 2020-10-26T19:02:01.155700Z

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

vlaaad 2020-10-26T19:02:12.155900Z

np!

vlaaad 2020-10-26T19:02:48.156100Z

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

vlaaad 2020-10-26T19:03:18.156300Z

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

1
seancorfield 2020-10-26T19:05:13.156600Z

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

seancorfield 2020-10-26T19:07:12.156800Z

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.

seancorfield 2020-10-26T19:07:52.157Z

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

vlaaad 2020-10-26T20:11:51.157200Z

cool!

vlaaad 2020-10-26T20:11:58.157400Z

very curious to see it

vlaaad 2020-10-26T20:15:53.157600Z

Please ping me when the tasks will go live!

seancorfield 2020-10-26T20:25:25.157800Z

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 🙂

👍 2