This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-24
Channels
- # aleph (4)
- # beginners (93)
- # cider (7)
- # cljs-dev (16)
- # cljsrn (5)
- # clojure (192)
- # clojure-dusseldorf (3)
- # clojure-italy (14)
- # clojure-russia (16)
- # clojure-serbia (1)
- # clojure-spec (85)
- # clojure-taiwan (1)
- # clojure-uk (79)
- # clojurescript (188)
- # code-reviews (9)
- # core-async (2)
- # crypto (1)
- # cursive (26)
- # datomic (21)
- # heroku (1)
- # hoplon (3)
- # jobs (7)
- # jobs-discuss (20)
- # jobs-rus (13)
- # off-topic (77)
- # om (15)
- # onyx (23)
- # pedestal (94)
- # planck (11)
- # proton (10)
- # protorepl (1)
- # re-frame (16)
- # ring (22)
- # ring-swagger (9)
- # rum (2)
- # specter (18)
- # testing (2)
- # untangled (14)
- # vim (12)
- # yada (58)
I'm curious about how people are handling routing in re-frame apps. Secretary seems fine for route matching, but I'm (perhaps out of ignorance) a bit dubious about accountant- seems like just a bit too much magic for my tastes at first glance. I've done a fair bit of react/redux with the react-router for redux, and while I think it has some issues (especially around asynchronicity) it does do some magic that I kind of like. Is this a case where people wind up rolling their own with re-frame, or am I missing a library?
I should add that I've been in npm-land long enough now that I've really started to lose my roll-my-own instincts.
I'm using bidi for routing and accountant for history. Here's the example: https://github.com/PEZ/reagent-bidi-accountant-example
I'm inclined to think, based on my experience writing SPAs in Angular and React/Redux, that having an easy default way of handling routing is crucial.
Hey, folks. How do you manage app-db with 3+ depth? My handlers looks like that:
(reg-event-db
:select-report
(fn [db, [_ id]]
(assoc-in db [:report-section :selected-report :id] id)))
Is it normal in re-frame?I have it on some maps. But I also have seperate method for some large maps. You could a function set-id and then use it to be something like
(set-id db id)
It add a level of abstraction which you may or may not like, but makes the event handler look more clean.Oh, re-frame has path middleware for handlers. Cool.
(reg-event-db
:select-report
(path [:report-section :selected-report])
(fn [report]
(assoc report :id id)))
@armed you can even do this (although I'm not sure it is clearer :-)):
(reg-event-db
:select-report
(path [:report-section :selected-report :id])
(fn [_ [_ id]]
id))
@mikethompson yes, but that scares me :)
What are people's thoughts on whether it's preferable to pass data down to subcomponents as properties vs having the subcomponents subscribe to the appropriate sub-tree of the app-db?
@timgilbert: My general approach - if the component makes no sense outside of the subscription context, or there are other substantial benefits to subscribing, then I subscribe directly If the component could be reused elsewhere in the app, or there are other benefits to passing things in directly, then I pass in props. Usually I go back and forth a few times between the 2 as I'm iterating on part that I'm not sure of, and it's usually a pretty simple change if I haven't gone too crazy.