This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-27
Channels
- # admin-announcements (42)
- # aws (15)
- # beginners (8)
- # boot (102)
- # cider (7)
- # clojure (141)
- # clojure-italy (10)
- # clojure-japan (4)
- # clojure-russia (26)
- # clojure-seattle (1)
- # clojurescript (239)
- # core-matrix (13)
- # cursive (19)
- # datascript (54)
- # datomic (21)
- # editors (2)
- # events (1)
- # hoplon (125)
- # instaparse (10)
- # jobs (3)
- # ldnclj (13)
- # ldnproclodo (1)
- # om (1)
- # onyx (2)
- # rdf (206)
- # re-frame (30)
- # reagent (7)
- # yada (4)
Hello, could you please take a look at my SO question here http://stackoverflow.com/questions/32236040/depend-on-both-input-arg-and-derived-collection-in-re-frame. Thanks in advance!
@nidu: ahh, yes. You are asking for dynamic subscriptions, for which we have developed a PR: https://github.com/Day8/re-frame/pull/108
But that's not a lot of help to you right now
@mikethompson: thanks, is there any workaround for such problems?
In my particular case i can move some
to app-state
and make it a part of subscription, but i'm pretty sure to stumble upon it later as it looks like a most common scenario for me)
It does come up sometimes.
We'll be merging in that PR soon
With the new release
But you are right that the workaround is: - put the data in @some into app-db .... - so it can be accessed in the handler itself
(defn some-list []
(let [bars (rf/subscribe [:bars])]
(fn []
[:ul
(for [[id b] @bars] ;; <---------- remember the @
[:li (:name b)])])))
(register-sub
:bars
(fn [db _]
(let [some (reaction (get @db :some)]
(reaction (get-in @db [:bar @some] ))))
;; we should NOT be using the name "some" ... I'm only doing it so it relates back to your question
See the remember the @
above
Your code didn't have it
And that can be a hard bug to find (the first time you do it)
I'm going to let you answer your own SO question .... so others can find it
Taking into account that you answered my question either you should answer it or tell me how can i reference you)
Kind of you ... but I don't need the reference ... just happy to see an answer posted for those that follow
@nidu: I pushed a snapshot to clojars a few days ago you can use which includes the patch https://clojars.org/re-frame/versions/0.5.0-SNAPSHOT
@danielcompton: thanks a lot! Gonna try it later today
Glad to see someone else requesting this feature, goes some way to validating its usefulness
I just started exploring re-frame so i'm not sure if i'll really need it. Maybe approach described above by mikethompson is actually sufficient. But the feature looks absolutely natural to use (at least from my unexperienced perspective).
@mikethompson: I had faced the same issue and came up with the solution after giving it quite a while.
and I thought I was the only one suffering the missing @ punishment
@danielcompton: thanks for the dynamic subscription
@mikethompson: Great, thanks! Really enjoying using re-com so far.
@danielcompton: just moved to your snapshot and my code works! Thats great!