This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-05
Channels
- # arachne (7)
- # architecture (3)
- # beginners (106)
- # cider (22)
- # clara (2)
- # cljs-dev (14)
- # cljsrn (12)
- # clojure (121)
- # clojure-china (1)
- # clojure-italy (2)
- # clojure-spec (22)
- # clojure-uk (32)
- # clojurescript (38)
- # community-development (45)
- # cursive (15)
- # datascript (6)
- # datomic (12)
- # defnpodcast (2)
- # emacs (8)
- # events (1)
- # fulcro (14)
- # immutant (6)
- # jobs (3)
- # jobs-discuss (6)
- # jobs-rus (3)
- # keechma (4)
- # keyboards (4)
- # leiningen (8)
- # luminus (1)
- # off-topic (91)
- # onyx (13)
- # parinfer (36)
- # re-frame (12)
- # reagent (23)
- # remote-jobs (1)
- # ring-swagger (3)
- # shadow-cljs (57)
- # specter (11)
- # sql (9)
- # uncomplicate (4)
- # vim (2)
- # yada (15)
@pontus.colliander The built-in parser on the client is written to use db->tree
for you.
There is nothing manual about it. You can use initial state to build an initial co-located state tree (which is auto-normalized on startup), and the queries are processed by the internal parser for you. Loading is a separate mechanism. So basically you can plug in an alternate network component/layer if you want, but other than that there is not much to write to make things work.
Hm I am trying to write a spec with generator for fulcro id/tempid and I'm failing:
(s/def :db/id (s/or :tempid (s/with-gen prim/tempid? (gen/fmap tempid/->TempId (gen/uuid))) :id (s/and integer? pos?)))
where s is spec.alpha, gen is spec.gen.alpha
After running (gen/sample (s/gen :db/id))
I get
ClassCastException clojure.test.check.generators.Generator cannot be cast to clojure.lang.IFn clojure.spec.alpha/spec-impl/reify--1987 (alpha.clj:888)
which is weird, as I cannot see how there is anything wrong.
@roklenarcic the generator needs to be a function of zero arguments that returns the generator, looks like you are returning the generator directly
this might work: (s/def :db/id (s/or :tempid (s/with-gen prim/tempid? #(gen/fmap tempid/->TempId (gen/uuid))) :id (s/and integer? pos?)))
and extra tip: you can replace (s/and integer? pos?)
with pos-int?
@wilkerlucio works now, thanks
it can be a bit confusing
when the arg is a generator and when a generator constructing fn
for spec, AFAIK it's always a constructing fn, directly generators are used on more inside levels (like when composing generators)
but it's easy to mess up, and over time we tend to remember better when to use what 🙂