This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-21
Channels
- # beginners (65)
- # boot (24)
- # cider (2)
- # clara (13)
- # cljs-dev (45)
- # clojure (48)
- # clojure-dusseldorf (2)
- # clojure-italy (69)
- # clojure-norway (1)
- # clojure-russia (5)
- # clojure-sanfrancisco (1)
- # clojure-spec (51)
- # clojure-uk (34)
- # clojurescript (312)
- # cursive (5)
- # datavis (1)
- # datomic (9)
- # duct (13)
- # editors (3)
- # emacs (2)
- # fulcro (11)
- # graphql (19)
- # hoplon (1)
- # immutant (2)
- # jobs (7)
- # jobs-discuss (38)
- # lein-figwheel (1)
- # luminus (6)
- # off-topic (2)
- # parinfer (10)
- # pedestal (1)
- # re-frame (9)
- # reagent (28)
- # reitit (1)
- # remote-jobs (12)
- # ring-swagger (26)
- # shadow-cljs (232)
- # slack-help (8)
- # tools-deps (29)
- # unrepl (29)
- # vim (10)
- # yada (31)
Is there a reason why a subscription gets only one source (the db or an other subscription)? I have started implementing my first app. I have a subscription :navig-params
which provides me URL parameters (which are stored by an event handler in the db). Then I have another subscription :items
which provides all "items". Now I wanted to create a third subscription :current-item
which would join data from :navig-params
and :items
to find the item which is selected by the url. But this seams not possible in re-frame. How is this join-Problem supposed to be solved in re-frame? Thank you!
I have some subscriptions that depend very much on the selection in the navbar I solved it like this
(re-frame/reg-sub
::middle
(fn [db]
(case (:selected-nav db)
:home [(:selected-nav db) (:transactions db)]
:bank-employee [(:selected-nav db) [(:employee-iban db) (:transactions db)]]
:client [(:selected-nav db) [(:login-status db) (:transfer-data db) (:transactions db)]]
:background [(:selected-nav db) nil]
[:non "error, should not be possible"])))
I’m not sure if thats a good way, but I like it better than having multiple layers of subscriptions and/or subsribe to the whole state
I try to get everyting a component needs on the same level in the main db atom, but that is not always possible
@witek subscriptions can have as many inputs as needed
There's no limit to 1
(reg-sub
:something
;; signal fn
(fn [_ _]
[(subscribe [:blah]) (subscribe [:other])]) ;; signal returns to inputs
;; computation fn
(fn [[blah other] ...] ;; two inputs are destructured as first arg
... use blah and other))
@witek we don’t provide a way to get access to db and another subscription as an input, because 99.99% of the time, you should just make two subscriptions as inputs, rather than chaining off app-db directly
Whenever app-db changes, all of the subscriptions that depend on it re-run, so you want to avoid having too many subscriptions on the root