This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-20
Channels
- # beginners (110)
- # boot (1)
- # cljs-experience (1)
- # clojure (58)
- # clojure-italy (4)
- # clojure-russia (1)
- # clojure-spec (4)
- # clojurescript (51)
- # cursive (2)
- # datomic (4)
- # devcards (4)
- # dirac (1)
- # figwheel (3)
- # fulcro (46)
- # hoplon (11)
- # om (4)
- # parinfer (7)
- # pedestal (1)
- # re-frame (11)
- # reagent (20)
- # specter (6)
- # unrepl (6)
(reg-fx
:ga/variation
(fn [_]
(let [variation (js/cxApi.chooseVariation)]
(js/console.log "var: " variation)
(reset! re-frame.db/app-db (assoc @re-frame.db/app-db :variation variation)))))
@lumpy Not quite sure if there is an established idiomatic way, perhaps :ga/variation nil
, or :ga/variation []
@souenzzo Could you clarify your question a bit? Are you looking for a tutorial on how to use spec with re-frame?
I'm looking for "patterns"
(defn foo [])
(s/fdef foo ...)
(rf/reg-event-db :foo foo)
I'm doing that at the moment. Just wanna see if this is the way or there is some smarter way to do.I've had some trouble using s/fdef
with re-frame too. The docs and todomvc example suggest using an interceptor to validate app-db after every event: https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/db.cljs https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/events.cljs
I think you can also try registering the original var e.g (rf/reg-event-db :foo 'foo)
to be able to register events, fdefs, and defns in any order you want. Not sure how idiomatic/efficient/safe that is though!
So for now, there is not an idiomatic way to spec functions. Ok. I will keep my pattern 😄
Lumpy, the docs say nil
@pesterhazy great find thanks