For a materialized view using the shorthand form, is it possible to pass a query variable to the input signal?
something like
(reg-sub
:id
;; input signals
:<- [:a entity-id] ;; means (subscribe [:a] is an input)
:<- [:b 2] ;; means (subscribe [:b 2] is an input)
;; computation function
(fn [[a b] entity-id other-query-v]
(calculate-it a b)))No, you have to use the full form.
Given an event handler with two effects, where the second effect depends on the first completing, can the following pattern be relied upon?
(rf/reg-event-fx
::dispatch-events-sequentially
(fn [_ _]
{:fx [[:dispatch [::first-event]]
[:dispatch [::depends-on-first-completing]]]}))
If dispatches occur in parallel, that would cause a problem. In that case, is the following recommended?
(rf/reg-event-fx
::depends-on-first-completing
(fn [_ _]
{}))
(rf/reg-event-fx
::first-event
(fn [_ _]
; calculate something
{:fx [[:dispatch [::depends-on-first-completing]]]}))
(rf/reg-event-fx
::dispatch-events-in-chain
(fn [_ _]
{:fx [[:dispatch [::first-event]]]}))The events will be handled in the right order. In fact, the :fx effect handler checks that its argument is sequential.
But if ::first-event uses :dispatch or some other "happens later" effects, then of course ::depends-on-first-completing will not see the results of those effects. That's why I mentioned before that "util" events become harder to use the more you rely on them.
Got it. Thanks again!