Siddharth Mishra
Siddharth Mishra

Reputation: 13

Pass params in reframe subscriptions to a chain function clojurescript

(re-frame/reg-sub
 ::current-effects-list
 (fn [[_ effect-type]]
   [(re-frame/subscribe [::available-effects])
    effect-type])
 (fn [[available-effects effect-type]]
   (filter (fn [{:keys [text value selected? type]}]
             (= effect-type type))
           available-effects)))

I want to pass the param effect-type to the next chain function as an argument, but I am new at Clojure, thus the effect-type is coming as null in the second chain function.

Upvotes: 1

Views: 350

Answers (1)

Victor Gil
Victor Gil

Reputation: 51

try this:


(re-frame/reg-sub
 ::current-effects-list
 (fn [[_ effect-type]]
   (re-frame/subscribe [::available-effects])) ; there is no need to return effect-type from here
 (fn [available-effects [_ effect-type]]
   (filter (fn [{:keys [text value selected? type]}]
             (= effect-type type))
           available-effects)))

Upvotes: 1

Related Questions