This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-19
Channels
- # aatree (33)
- # admin-announcements (70)
- # alda (6)
- # aleph (2)
- # announcements (6)
- # aws (7)
- # beginners (40)
- # bitcoin (1)
- # boot (138)
- # cider (24)
- # cljs-dev (9)
- # cljsjs (18)
- # cljsrn (35)
- # clojars (4)
- # clojure (211)
- # clojure-art (4)
- # clojure-austria (2)
- # clojure-hamburg (8)
- # clojure-russia (66)
- # clojure-sg (3)
- # clojured (1)
- # clojurescript (73)
- # cursive (9)
- # datomic (124)
- # dirac (8)
- # editors (3)
- # emacs (13)
- # euroclojure (10)
- # hoplon (207)
- # jobs (4)
- # ldnclj (27)
- # lein-figwheel (3)
- # leiningen (10)
- # mount (5)
- # music (1)
- # off-topic (9)
- # om (92)
- # onyx (36)
- # perun (30)
- # proton (47)
- # re-frame (11)
- # reagent (11)
- # ring-swagger (7)
- # yada (2)
thanks @mikethompson
--------------- Dear all, consider using Dirac https://github.com/binaryage/dirac ----------------
I'm looking for a way to dispatch events when certain parts of the state changes
Like: I want to :fetch-search
when :filters
change
Would this be a bad idea?
I'm writing too much dispatches that dispatch to :fetch-search
@hugobessaa: :fetch-search
doesn't sound like an event. It sounds like that should be a normal function that's called in event handlers that change :filters
.
I understand your concern about preventing repitition and wanting to hook into "when :filters
change. I believe that according to the idea and intention of re-frame there is no such hook and you should organize your events in a way that it doesn't feel like duplication when you call fetch-search
in a lot of places: You're already setting :filters
in a number of places (afaiu), instead in all these places you could have a function (fn set-filters [db new-filters] (do (fetch-search new-filters) (assoc db :filters new-filters)))
or similar.
@mbertheau: thanks for your feedback! It really does look like a function
@hugobessaa: yep, I agree with @mbertheau. Having said that, the on-change
middleware might be useful, maybe https://github.com/Day8/re-frame/blob/master/src/re_frame/middleware.cljs#L197-L235