This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-23
Channels
- # bangalore-clj (1)
- # beginners (23)
- # boot (90)
- # cljs-dev (133)
- # cljsrn (5)
- # clojure (104)
- # clojure-austin (1)
- # clojure-belgium (2)
- # clojure-dev (12)
- # clojure-gamedev (4)
- # clojure-italy (2)
- # clojure-russia (6)
- # clojure-spec (30)
- # clojure-uk (117)
- # clojurescript (197)
- # core-async (25)
- # cursive (9)
- # datomic (95)
- # devops (1)
- # dirac (49)
- # emacs (1)
- # hoplon (3)
- # immutant (10)
- # lein-figwheel (2)
- # luminus (5)
- # off-topic (43)
- # pedestal (1)
- # protorepl (1)
- # re-frame (13)
- # sql (5)
- # untangled (1)
is there a way to subscribe to the db and a subscription in the chained subscription
i.e. if I want access to the db as well as some derived data
@danieleneal my guess is that the "right way" is to create subscriptions for each of the bits of the db you also need access to. But a gross hack would just be to create a "top-level" @app-db based subscription and use that.
ah ok
gross hack here we come
(reg-sub :db identity)
I think only if the output of the subscription is different
(reg-sub :some-other-thing :<- [:db] :<- [:derived-data] (fn [db derived-data] (some-other-function db derived-data)))
Notes:
1. That subscription handler will rerun everytime anything in db
changes. So you wouldn't want it to be an expensive computation.
2. It is kinda unusual to depend on all of db. Normally a subscription depends on some part/path within it.
@mikethompson 🙂 thanks! So it kind of makes sense to make extra subscriptions that just select the path first, like so (reg-sub :some-path (fn [db] (get db :some-path))
and (reg-sub :some-expensive-computation :<- [:some-path] (fn [data-at-some-path] (some-expensive-function data-at-some-path))
to avoid the expensive computation running unnecessarily
i think so