2022-10-19

Published: Nov 01, 2022Last modified: Apr 05, 2023
Word count: 86

clerk recompute notebook button

A button you can add to a clerk notebook that will recompute the entire notebook when clicked.

^{::clerk/viewer
  {:name         :recompute-button
   :transform-fn clerk/mark-presented
   :render-fn
   '(fn [notes]
      (v/html
        [:button
         {:class    ["bg-blue-800" "hover:bg-blue-500"
                     "text-slate-300" "font-bold"
                     "py-2" "px-4" "m-1" "rounded"]
          :on-click (fn [_] (v/clerk-eval `(nextjournal.clerk/recompute!)))}
         "recompute!"]))}}
{:some :data}

Intended for small things, when hacking your notebook together.

A smarter way to achive this might look like getting your ::clerk/no-cache game going, then wiring up some listeners to wisely update the data sources - this way you get the incremental caching. This is a _full_ recomputation of the notebook, which could be more work than is necessary.