This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-18
Channels
- # architecture (25)
- # beginners (57)
- # boot (3)
- # cider (38)
- # clara (6)
- # cljsrn (6)
- # clojure (54)
- # clojure-china (4)
- # clojure-greece (1)
- # clojure-italy (3)
- # clojure-romania (1)
- # clojure-russia (7)
- # clojure-spec (68)
- # clojure-uk (46)
- # clojurescript (73)
- # community-development (2)
- # core-async (7)
- # cursive (17)
- # datomic (143)
- # duct (2)
- # emacs (12)
- # events (5)
- # figwheel (3)
- # fulcro (15)
- # hoplon (19)
- # jobs (12)
- # jobs-discuss (85)
- # nginx (3)
- # off-topic (111)
- # onyx (7)
- # other-languages (1)
- # re-frame (30)
- # reagent (19)
- # remote-jobs (1)
- # ring (7)
- # rum (1)
- # shadow-cljs (18)
- # spacemacs (4)
- # specter (4)
- # sql (24)
- # test-check (1)
- # unrepl (10)
- # vim (6)
- # yada (1)
the data on certain db key is being updated correctly, but the subscription doesn't work
(def state->pouch_sub (keyword (str pouchDatabaseName "-sub")))
(re-frame/reg-sub
state->pouch_sub
(fn [db [_ _]]
(.log js/console (clj->js db) "the whole db")
((keyword pouchDatabaseName) db)))
(let [freshStateData (re-frame/subscribe [state->pouch_sub])]
(.log js/console @freshStateData "subscription")))
Is it wrong?I need to double check when I'm back at my desk, but I'm fairly sure the db passed into your subscription function is a reagent atom; you need to dereference it within the sub function for it to realize when the app database changes.
but my router is dereferences it like this
(defn main-panel []
(let [active-panel (re-frame/subscribe [::active-panel])]
[pages/panels @active-panel]))
and it worksFor a simple reference, this is one of the super basic subscriptions in one of my apps: (defn app-view "Which view the user is currently looking at." [db _] (reaction (:app/view @db)))
@melvoloskov perhaps you’d find https://github.com/Day8/re-frame/blob/master/docs/SubscriptionFlow.md useful