Fork me on GitHub
#re-frame
<
2016-10-28
>
lsnape15:10:15

Giving my app a first dose of sane effect handling using reg-event-fx and loving it.

shaun-mahood16:10:23

I'm giving a talk on re-frame at this year's Conj! http://2016.clojure-conj.org/speakers/ If you have any specific thoughts on things I should cover, or areas you struggled with when getting started, please DM me and we can chat about it.

curlyfry17:10:11

@shaun-mahood: Awesome, will definitely watch!

richiardiandrea17:10:41

@shaun-mahood for sure the cofx/fx stuff needs a proper talk 😄

grant17:10:18

Is there a good way to dynamically set the results from the input function when registering a subscription? Something where when as reference to some b changes, the input signal changes too. I'd like to not have to subscript to all of the bs to make it happen.

(reg-sub
  :nested-a-sub
  (fn [q-vec d-vec]
    (let [[_ a-ref] q-vec]
      [(subs/subscribe [:a-sub a-ref])
       (subs/subscribe [:b-sub (:refd-b @(subs/subscribe [:a-sub a-ref]))])]))
  (fn [[a b] [_]]
    ...
    {:a/1 "a"
     :a/2 3
     :a/refd-b {:b/1 "w"
                :b/2 12}}))

grant18:10:45

And to clarify the last sentence, I'd like to not have to subscript to all of the bs to make it happen.

grant18:10:25

(reg-sub
 :nested-a-sub
 (fn [q-vec d-vec]
   (let [[_ a-ref] q-vec]
     [(subs/subscribe [:a-sub a-ref])
      (subs/subscribe [:all-bs-sub])]))
 (fn [[a all-bs] [_]]
   (let [b-ref (get a :refd-b)
         b (get all-bs b-ref)]
     ...
     {:a/1 "a"
      :a/2 3
      :a/refd-b {:b/1 "w"
                 :b/2 12}})))

grant18:10:23

Unless that is actually the recommended way to do things.

kauko18:10:31

You need two for multiline

grant18:10:55

Ah, thanks.

mattly19:10:16

is there any way to declaratively do multiple dispatch with reg-event-fx ?

grant19:10:09

{:dispatch-n [[:event1]
              [:event2 arg]
              ...]}

grant19:10:49

Well, not that I can get them to line up correctly, but you get the idea, use :dispatch-n.

mattly23:10:41

thanks - I didn't see that documented