This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-25
Channels
- # announcements (21)
- # babashka (7)
- # beginners (27)
- # calva (7)
- # chlorine-clover (3)
- # cider (1)
- # clerk (21)
- # clojure (24)
- # clojure-europe (28)
- # clojure-finland (3)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (2)
- # clojurescript (13)
- # clr (2)
- # conjure (1)
- # consulting (1)
- # datahike (1)
- # datomic (13)
- # fulcro (3)
- # graalvm (33)
- # gratitude (7)
- # honeysql (7)
- # humbleui (12)
- # hyperfiddle (26)
- # interop (11)
- # introduce-yourself (4)
- # jobs-discuss (8)
- # lsp (26)
- # malli (6)
- # nbb (11)
- # polylith (26)
- # practicalli (1)
- # rdf (3)
- # re-frame (7)
- # reitit (10)
- # releases (2)
- # shadow-cljs (1)
- # tools-deps (15)
Is it possible in malli to instrument a function on the fly? My use case is wanting to ensure symmetric re-frame db handlers that always receive and return the db. I would like to instrument programmatically in my reg-event
function. Example:
(defn my-updater-event [db k v]
(update db k v))
(instrument-this-fn my-updater-event [:=> [:cat :map [:* :any]] :map])
It's possible in CLJ with alter-var-root
- and that's how built-in Malli instrumentation works.
In CLJS, it might be possible with set!
: https://clojurians.slack.com/archives/C03S1L9DN/p1604308689481100
But no clue whether it'll survive advanced optimizations and, even if it does now, whether it's something one can rely on.
I would probably write a macro that works like defn
but also accepts a schema and produces an already instrumented function.
yup, I did the macro experiment earlier and it’s pretty nice. Probably makes more sense.
There is already such a function, in https://github.com/metosin/malli/blob/master/src/malli/experimental.cljc#L71