This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-12
Channels
- # aleph (8)
- # announcements (9)
- # babashka (15)
- # beginners (91)
- # calva (54)
- # chlorine-clover (3)
- # cider (25)
- # clj-kondo (9)
- # cljfx (4)
- # cljsrn (12)
- # clojure (40)
- # clojure-australia (2)
- # clojure-europe (77)
- # clojure-nl (10)
- # clojure-spec (22)
- # clojure-uk (9)
- # clojurescript (39)
- # conjure (12)
- # cursive (8)
- # datascript (17)
- # datomic (22)
- # emacs (2)
- # expound (6)
- # fulcro (25)
- # kaocha (7)
- # malli (9)
- # meander (5)
- # off-topic (13)
- # pathom (8)
- # pedestal (5)
- # portal (1)
- # rdf (58)
- # re-frame (65)
- # reagent (15)
- # sci (3)
- # shadow-cljs (50)
- # test-check (6)
- # testing (3)
- # tools-deps (1)
- # vim (7)
- # xtdb (10)
@love.lagerkvist I'm using re-frame.core/reg-global-interceptor
to verify the app-db matches my schema in every change, and prints an console warning if it doesn't conform. But re-frame.app-db is just a normal map (live inside an reagent.atom), so it's nothing special when using it with malli IMO.
merged #277, non-breaking disabling & configuration of sci. Will make a 1.0.0 issue with suggestion to make swappable & explicit evaluator. Thanks @borkdude @steveb8n
@ikitommi note that termination safe does have impact on performance of realizing seqs (since it’s checked). I’m not sure if the issue about execution time is fundamentally solvable.
It is one of the harder problems in comp.sci ;) With Malli & sci, I concider safety as more important. Following the issue & pr on sci-side, happy to incorporate anything that is found for this.
I think the fundamental solution would be to run the sci expression in a thread on the JVM and kill it if it takes too long or in a webworker in the browser and do the same.
@wxitb2017 that sounds about right, I’ll do that. However, I was also thinking if it was possible to co-locate/generate/properly infer an inital app-db directly from malli. It would be really nice to have a single source of truth, kind of like a reitit router with views, coercion and controllers. (it’s probably super possible and I have to dig more into malli or a very bad idea)
You could have a Malli schema defined for the app-db, with default and create the initial state from those, e.g.
(defn create [?schema]
{:validator (m/validator ?schema)
:explainer (m/explainer ?schema)
:initial (m/decode ?schema nil (mt/default-value-transformer))})
(create [:map {:default {}}
[:user [:map {:default {}}
[:first-name [:string {:min 1, :default ""}]]
[:last-name [:string {:min 1, :default ""}]]]]])
;{:validator #object[...],
; :explainer #object[...],
; :initial {:user {:first-name "", :last-name ""}}}
inferring is powerful, but not fully accurate, e.g. is something a vector of things of a tuple of always 2.