Fork me on GitHub
Drew Verlee18:02:23

Given i want to pass an argument to my subscription e.g (subscribe [:id 1]) how should i organize my reg-sub such that it can flow to the input signals? e.g :<- this doesn't seem to work:

  ;; input signals 
  :<- [:b foo]      ;; means (subscribe [:b foo] is an input)

  ;; computation function
  (fn [[b] db [_ foo]
       (something b)))

Drew Verlee18:02:40

i guess this might be a matter of organization, maybe input signal should be coupled to foo before hand like: selected-b


The :<- is just a shorthand syntax that exists specifically for parameterless signals. If you need parameters, you can just use the full form, the one that accepts a function:

(reg-sub :id
  (fn [[_ foo]]
    (subscribe [:b foo]))
  (fn [b _]
    (something b)))

Drew Verlee18:02:15

that makes sense, thanks.

👍 1