practicalli / clojure

Practicalli Clojure REPL Driven Development
https://practical.li/clojure/
Creative Commons Attribution Share Alike 4.0 International
91 stars 36 forks source link

portal submit custom logic #449

Open practicalli-johnny opened 1 year ago

practicalli-johnny commented 1 year ago

Portal submit can include custom code

useful for values that don't support metadata directly but where you still want to customize display

Example conditionally add date

(defn ->date [value]
  ^{:portal.viewer/default :portal.viewer/hiccup}
  [:portal.viewer/relative-time value])

(defn my-submit [value]
  (p/submit
   (cond
     (date? value)
     (->date value)
     :else value)))

(add-tap #'my-submit)

Reference