What do you suggest?
re-frame currently supports the :<- [...] sugar syntax in reg-sub to perform a literal (subscribe) as an input signal (we could call this 1-arity) and :-> fn and :=> fn to provide a 1-arity or multi-arity computation fn, respectively.
Frequently, I find myself wanting to chain multi-arity subscriptions such that, for example:
; EG: I have an ID I specifically want to reference:
(<sub [:my-sub id])
; *or* EG: I want to reference some shared "current" ID:
(<sub [:my-sub])
Perhaps this is an anti-pattern, but it has felt like a natural way to do things, and for simple subscriptions can work well with the :=> sugar.
However, if I want to use that multi-arity subscription as input to another subscription, I start to get in trouble:
; This doesn't work because it only subscribes to the 1-arity version
(reg-sub
:dependent-sub
:<- [:my-sub]
:-> computation)
; Instead, I have to do:
(reg-sub
:dependent-sub
(fn [[_ id]]
(subscribe [:my-sub id])
:-> computation)
What if, instead, we could write this as:
(reg-sub
:dependent-sub
:<= [:my-sub]
:-> computation)
and have the query-vector "params" conj'd into the provided subscription vector, similar to how :=> works on the computation side? Is this a terrible idea?
What do you suggest?
re-frame currently supports the
:<- [...]sugar syntax inreg-subto perform a literal(subscribe)as an input signal (we could call this 1-arity) and:-> fnand:=> fnto provide a 1-arity or multi-arity computation fn, respectively.Frequently, I find myself wanting to chain multi-arity subscriptions such that, for example:
Perhaps this is an anti-pattern, but it has felt like a natural way to do things, and for simple subscriptions can work well with the
:=>sugar.However, if I want to use that multi-arity subscription as input to another subscription, I start to get in trouble:
What if, instead, we could write this as:
and have the query-vector "params" conj'd into the provided subscription vector, similar to how
:=>works on the computation side? Is this a terrible idea?