If the default behavior of Portal's tap list isn't exactly what you need, you can implement your own with any behavior your require.
For this example, let's assume you have the following constraints:
:id
and a :time
:id
, :value
, and :time
Firstly, lets specify metadata to tell Portal how to render the tap-list:
(def viewer
{:portal.viewer/default :portal.viewer/table
:portal.viewer/table {:columns [:id :value :time]}})
(def tap-list (atom (with-meta [] viewer)))
Secondly, setup a custom submit function to implement the stated constraints:
(def ids (atom 0))
(defn submit [value]
(let [id (swap! ids inc)]
(swap! tap-list
(fn [taps]
(conj
(if (< (count taps) 25)
taps
(subvec taps 1))
{:id id
:value value
:time (java.util.Date.)})))))
Finally, you can wire all this up into Portal with the following:
(add-tap #'submit)
(require '[portal.api :as p])
(p/open {:value tap-list})
(tap> :hello)
Which looks something like:
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close