Fork me on GitHub
#re-frame
<
2015-08-27
>
gregg05:08:07

Yep, the supported events are: :on-key-down :on-key-press and :on-key-up.

nidu06:08:23

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!

mikethompson07:08:00

@nidu: ahh, yes. You are asking for dynamic subscriptions, for which we have developed a PR: https://github.com/Day8/re-frame/pull/108

mikethompson07:08:06

But that's not a lot of help to you right now

nidu07:08:49

@mikethompson: thanks, is there any workaround for such problems?

nidu08:08:22

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)

mikethompson08:08:23

It does come up sometimes.

mikethompson08:08:33

We'll be merging in that PR soon

mikethompson08:08:36

With the new release

mikethompson08:08:45

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

mikethompson08:08:27

(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

nidu08:08:51

ok, got it! Thanks a lot!

mikethompson08:08:21

See the remember the @ above

mikethompson08:08:36

Your code didn't have it

mikethompson08:08:03

And that can be a hard bug to find (the first time you do it)

mikethompson08:08:47

I'm going to let you answer your own SO question .... so others can find it simple_smile

nidu08:08:34

Taking into account that you answered my question either you should answer it or tell me how can i reference you)

mikethompson08:08:09

Kind of you ... but I don't need the reference ... just happy to see an answer posted for those that follow

nidu08:08:49

Ok, as you wish

danielcompton10:08:52

@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

nidu10:08:41

@danielcompton: thanks a lot! Gonna try it later today

danielcompton10:08:03

Glad to see someone else requesting this feature, goes some way to validating its usefulness

nidu10:08:31

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).

code-shoily12:08:42

@mikethompson: I had faced the same issue and came up with the solution after giving it quite a while.

code-shoily12:08:10

and I thought I was the only one suffering the missing @ punishment

code-shoily12:08:56

@danielcompton: thanks for the dynamic subscription

shaun-mahood14:08:02

@mikethompson: Great, thanks! Really enjoying using re-com so far.

nidu17:08:24

@danielcompton: just moved to your snapshot and my code works! Thats great!