This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-10
Channels
- # asami (41)
- # babashka (24)
- # beginners (48)
- # calva (41)
- # cider (10)
- # clj-commons (20)
- # clj-kondo (2)
- # cljdoc (8)
- # clojure (131)
- # clojure-australia (4)
- # clojure-europe (17)
- # clojure-hungary (2)
- # clojure-india (2)
- # clojure-nl (3)
- # clojure-uk (1)
- # clojurescript (12)
- # community-development (6)
- # core-logic (4)
- # cursive (11)
- # datomic (22)
- # emacs (25)
- # events (1)
- # exercism (2)
- # fulcro (30)
- # helix (5)
- # honeysql (6)
- # hugsql (3)
- # integrant (12)
- # introduce-yourself (4)
- # lsp (5)
- # malli (5)
- # nextjournal (31)
- # off-topic (4)
- # pedestal (3)
- # portal (51)
- # reitit (33)
- # remote-jobs (1)
- # shadow-cljs (12)
- # sql (10)
- # vim (7)
- # xtdb (37)
Hi! Just started playing with Clerk, wonderful tool! One question though: is it possible to prevent a form from rendering? I have some deeply nested forms that Clerk tries to render completely and it slows down the browser to the point it is not usable anymore.
Hi, is that using the latest version of Clerk (0.3.220)? If not, please try an upgrade. If yes, I'd love to see the date, can you share it?
Yes it’s the latest version. Basically it’s a any data produced by libraries like https://github.com/davidsantiago/hickory that parse HTML into edn. So it’s basically trees where each level does not have that many children, but the depth of the tree can be huge at places.
I'm trying out Clerk, it's really promising to me, I like it seems to be similar to a hot-reloading clojurescript project where you keep your namespaces fresh. I do have an issue:
(require '[ :as io]
'[xtdb.api :as xt])
(defn start-xtdb! []
(letfn [(kv-store [dir]
{:kv-store {:xtdb/module 'xtdb.rocksdb/->kv-store
:db-dir (io/file dir)
:sync? true}})]
(xt/start-node
{:xtdb/tx-log (kv-store "data/dev/tx-log")
:xtdb/document-store (kv-store "data/dev/doc-store")
:xtdb/index-store (kv-store "data/dev/index-store")})))
(def node (let [_run-at #inst "2021-11-10T15:09:43.090-00:00"]
(start-xtdb!)))
But start-xtdb!
seems to be called again, which causes the notebook page to error because of lockfiles in the db. I expected the _run-at
trick would work for this kind of issue.great to hear you find it promising. So in general I’d advise against using the run-at / inst trick for stateful things you only want to happen once since they will not be called if clerk caches them across restarts
also Clerk has a threshold built in and doesn’t consider things that execute faster than that worth caching
can you use some other mechanism like an atom or another side-effectful check to make sure this happens only once?
I haven’t done much / any of stateful things like that so I’m eager to learn what the best approach here is 😼
Ah, the threshold thing explains my surprise. I'm also doing a bunch of stateful mutations to the db in the namespace but it's not a big deal. Although perhaps meta for "cache this anyway" would be useful. Or as @U04V15CAJ said, in the cljs world I use defonce
for this stuff!
(declare node)
(def node
(if (bound? (var node))
node
(start-xtdb!)))
seems to do the trick without turning into an atomdoes that work? Though I think you should tag that with ^:nextjournal.clerk/no-cache
then. Maybe something we should do automatically?
isn't that the idea of defonce
? execute only once, regardless of how many times you reload
Is it possible in Clerk to render a form's output without its source code (like how Nextjournal provides a "hide source" option)?
main difficulty is the names of the options, think we might want to allow hiding the code and/or results with and without the ability to unhide them
I think there are 2 use cases: 1. hide all code 2. hide individual code forms How to realize this is indeed not simple
Another small Clerk release following yesterday’s table viewer release: Clojars: https://clojars.org/io.github.nextjournal/clerk/versions/0.3.233 Changelog: https://github.com/nextjournal/clerk/blob/93c19314e4e657075176667781d38c0c15fa29ef/CHANGELOG.md#03233-2021-11-10