Fork me on GitHub
#re-frame
<
2020-12-11
>
Felipe Marques15:12:00

Hi guys, I was wondering if it would be ok to create a subscription like this:

(reg-sub
  :visible-todos

  ;; signal function - returns a vector of two input signals
  (fn [todos-source-sub _]
    [(subscribe todos-source-sub)
     (subscribe [:showing])])

  ;; the computation function - 1st arg is a 2-vector of values
  (fn [[todos showing] _]
    (let [filter-fn (case showing
                      :active (complement :done)
                      :done   :done
                      :all    identity)]
      (filter filter-fn todos))))

Felipe Marques15:12:51

The basic idea is passing another subscription spec (like [::my-personal-todos]) as a query param to define the input-signal for the subscription

p-himik15:12:05

LGTM But I bet not everyone will agree.