This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-23
Channels
- # beginners (63)
- # cljs-dev (1)
- # cljsjs (1)
- # cljsrn (11)
- # clojure (208)
- # clojure-berlin (2)
- # clojure-dusseldorf (5)
- # clojure-italy (5)
- # clojure-norway (56)
- # clojure-russia (7)
- # clojure-spec (85)
- # clojure-uk (27)
- # clojurescript (191)
- # core-async (73)
- # cursive (4)
- # datomic (62)
- # defnpodcast (1)
- # hoplon (2)
- # jobs-rus (1)
- # juxt (14)
- # keechma (1)
- # leiningen (1)
- # lumo (126)
- # off-topic (2)
- # om (11)
- # onyx (27)
- # pedestal (52)
- # planck (21)
- # powderkeg (1)
- # re-frame (32)
- # reagent (14)
- # ring-swagger (1)
- # rum (3)
- # slack-help (19)
- # specter (23)
- # untangled (32)
- # vim (7)
- # yada (43)
I have a question about Re-frisk. Is there a reason why enable-re-frisk!
is called after dispatch-sync
in the code in the README here: https://github.com/flexsurfer/re-frisk#web-applications-with-re-frame
Since there is no special reason to put it in between, it might be more obvious to call it before calling re-frame’s dispatch-sync in the README?
Hey! I just started using re-frame as the client side data store in my web app, so this might be a really basic question - what is considered a good practice: having a small set of events which accept fn to do the actual change on the reframe-app-db or having a large number of events each of which cater to the smallest granularity of change?
To give a more concrete example lets say we have a number of input forms on my web page each of which correspond to a key in the app-db. So the question boils down to - should I have one generic event which takes in an update-fn and some param to identify the input field being updated or have specific events for each of the input field?
@borkdude my apprehension of using the generic event approach was that the value dispatched would be a fn closed over the actual value thereby reducing the visibility while debugging. Are there other downsides to that approach that I should be aware of?
Heh. I did that already and it’s working fine. But I vaguely remember reading it somewhere in the re-frame docs that events should be dispatched with values, so I refactored to have multiple events, which works but is more verbose imo.
But if there aren’t any red flags or caveats that I should be aware of while following the generic event approach I would go back to the previous implementation. Thanks!
When you have different things to dispatch based on the fields it makes sense to factor out events
@udit I think your abstracted mutation that puts app db paths into the view is the reciprocal of this warning to avoid doing that with the subscriptions side: https://github.com/Day8/re-frame/blob/master/docs/SubscriptionsCleanup.md#a-final-faq
(reg-sub
:extract-any-path
(fn [db path]
(get-in db path))
Did you steal this from my code??? 😡 😠it's just so tempting to do that, right? But then you might as well just get-in from the state atom itself
@udit it might also be a sign of a poorly designed db schema. for example, maybe accessories should be more universal, rather than a different handler for each character class. or the handler could look up the character class and then add the [:magician]
at the beginning. Then you'd have something more like (rf/reg-event-db ::accessories-update :wand #(new-wand))
which could work for a warrior class: (rf/reg-event-db ::accessories-update :axe #(new-axe))
... ?
Thanks @U07KXN95L! My add-wand fn did reside in the view. I have read the follies of a generic subscription in the link that you shared. That was helpful in understanding why is it a bad practice. As for accessory being a top level entity in the app-db, it’s sort of like a nested form inside of magician and a wand is an input element amongst others.
Then again, that (new-wand)
function needs to live somewhere, and probably not in the view, so you could just have (rf/dispatch ::events/accessories-update :new-wand)
in the view and handler would call the (new-wand)
.
@udit I would definitely recommend a larger number of specific subscriptions and event handlers over a smaller number. Regardless of this choice, you should almost never pass functions as values in your events. Passing data is much much better for debuggability and observability purposes
Hey all, anyone had experience with ring-anti-forgery and re-frame-http-fx?
we haven't, but would be interested in seeing what you come up with
happy to take a PR to make it easier to use in re-frame-http-fx too