day8 / re-frame

A ClojureScript framework for building user interfaces, leveraging React
http://day8.github.io/re-frame/
MIT License
5.42k stars 715 forks source link

[Enhancement]: Adding syntax sugar :<= for input subscriptions taking the same query vectors. #762

Closed pavel-klavik closed 2 years ago

pavel-klavik commented 2 years ago

What do you suggest?

I like the new additions for describing simple computation-fns in reg-sub (https://day8.github.io/re-frame/api-re-frame.core/#reg-sub). But I think there is one currently missing which would make writing certain subscriptions much easier. Suppose that I have the following subscriptions:

(reg-sub :a    ;; taking a single parameter id
  ...)

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

I would love to be able to write the second subscription as

(reg-sub :b
  :<= [:a]
  :-> :foo)

So the implementation would take the query params of :b and put them inside the input subscription :a. This would also be roughly compatible with the new syntax sugar :=>.

superstructor commented 2 years ago

Thanks for the proposal. Happy to take a PR for this @pavel-klavik

mike-thompson-day8 commented 2 years ago

Sorry, but I need to knock this idea on the head.

If anything, I'd like less syntactic sugar in the core, not more. I regret what little we do have. I should have kept it simple and let people do their own, addional wrappers for whatever sugar they wanted (everyone's aesthetic is different).

Sorry for the conflicting messages, I hope you didn't start on the PR