Fork me on GitHub
#re-frame
<
2019-05-22
>
hoopes13:05:25

(rf/reg-sub                                     
  ::series                                     
  (fn [db [_ ser-id]]                                     
    (get-series ser-id)))                                     
                                     
(rf/reg-sub                                     
  ::status                                     
  :<- [::series [_ ser]] ;; <- what goes here for args?                                     
  (fn [ser _]                                     
    (:status ser))) 

hoopes13:05:26

can i pass arguments to an "upstream" subscription? my sub looks like (rf/subscribe [::that-ns/status ser]) - there isn't an example in https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/subs.cljs (unless i'm missing it...)

minimal13:05:26

you can. e.g. you could hard code a sub for an id with

(rf/reg-sub                                     
  ::status-1                                     
  :<- [::series 1]
  (fn [ser _]                                     
    (:status ser)))

hoopes13:05:30

i was hoping to not hard-code it though, and take the argument from the rf/subscribe

minimal14:05:02

that works as well

manutter5114:05:33

I think if you skip the syntactic sugar and write out the signal function, you’ll get the same query vector as the subscription function:

(rf/reg-sub
  :my-app/my-sub
  (fn [query-v]
    (let [[_ arg] query-v]
      (rf/subscribe [:my-app/my-other-sub arg]))
  (fn [sig]
    (get sig :some-attr)))

manutter5114:05:32

I’m on break at a company day-long mtg, so I don’t have time to fire up a repl and check that, but I’m referring to the todomvc example here, https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/subs.cljs, starting about line 31

hoopes14:05:41

got it - much appreciated, @minimal and @manutter51!!! Thanks!