This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-08
Channels
- # announcements (3)
- # babashka (3)
- # beginners (25)
- # calva (12)
- # cider (58)
- # clara (11)
- # clj-kondo (19)
- # cljsrn (2)
- # clojure (84)
- # clojure-austin (1)
- # clojure-europe (5)
- # clojure-nl (4)
- # clojure-spec (23)
- # clojure-uk (53)
- # clojuredesign-podcast (5)
- # clojurescript (24)
- # core-async (57)
- # cursive (16)
- # datomic (39)
- # emacs (1)
- # fulcro (40)
- # funcool (2)
- # graphql (17)
- # jackdaw (31)
- # jobs (2)
- # joker (3)
- # malli (7)
- # off-topic (12)
- # re-frame (9)
- # reagent (2)
- # reitit (1)
- # ring (4)
- # shadow-cljs (170)
- # sql (36)
- # tools-deps (5)
- # xtdb (20)
I’m having a problem with subscriptions, and I’m not sure how to proceed to try and resolve it. I’m feeding input signals through a series of subscriptions, and at a certain point they just stop flowing.
(rf/reg-sub
:user-form/modal-group-filter
:<- [:forms/user-form]
(fn [user-form]
(prn {:filter (get-in user-form [:modal-group-filter :input/value])})
(:modal-group-filter user-form)))
(rf/reg-sub
:user-form/modal-group-filter-value
:<- [:user-form/modal-group-filter]
(fn [filter-data]
(println "Intermediate sub returning" (pr-str (:input/value filter-data)))
(:input/value filter-data)))
This is in the overall context of typing a search string into an input field to filter a large list of groups down to a manageable size. As I type, my debug string is printing out the {:filter "foo"}
output, one for each character I type. The debug printout in the dependent subscription, however is never printed. It prints once when the component first renders, but does not update as I type.For me it looks like reagent somehow counts (:modal-group-filter user-form)
as unchanged.
Yeah, that’s what it looks like. I use the same pattern almost everywhere, and they all work fine. It’s just this one link in the signal tree that fails.
I wonder if it has anything to do with the fact that the input field subscribes to the sub that does work.
IOW multiple subscriptions to the same sub. :thinking_face:
Looking at the reg-sub
code you could try to use traces that are baked into re-frame
https://github.com/Day8/re-frame/blob/72f06966b0e6bb40c35607629a5301ef3a9e6640/src/re_frame/subs.cljc#L368
@manutter51 Are you dereferencing the two subscriptions from the same exact place?