Fork me on GitHub
#portal
<
2024-03-14
>
sheluchin17:03:14

Cross-posting from #beginners: Is there some way to prevent Portal from printing infinite sequences? https://clojurians.slack.com/archives/C053AK3F9/p1710434608001979

djblue20:03:09

Currently, Portal doesn't try to deal with infinite seqs but you can deal with them in a custom submit function such as:

(require '[clojure.walk :as walk])

(defn truncate-seqs [v]
  (walk/prewalk #(if (seq? %) (take 10 %) %) v))

(add-tap (comp portal.api/submit truncate-seqs))

(tap> (range))

nice 1
djblue20:03:48

In very early versions of Portal, it did try to handle infinite lazy seqs, but it made the client much more complicated and I found myself not needing it very often.