I ended up just putting an empty...
(fn [_ _]
[])
... to force the code into "layer 3"/"materialized view" and that seems to
work well: successfully decoupled recalculation of this function from every
single unrelated *app-db* update and the nested *reactions*/*subscriptions*
seems
to remain reactive.
My new code with change in *green*:
(rf/reg-sub
:foo
* (fn [_ _]*
* [])*
(fn [_ [_ x y z] _]
(let [A @(subs/subscribe [:l x y])
B @(subs/subscribe [:m y z])
C @(subs/subscribe [:n x y z])
D @(subs/subscribe [:o])]
(into #{}
(apply concat
(for [a A
b B
:let [u (first C)]
:when @(subs/subscribe [:p a u)]
(for [c C
:when (< 0 @(subs/subscribe [:q a u c]))]
(list a u c))))))))
On Thursday, September 7, 2017 at 4:47:41 AM UTC-4, Jakub Ner wrote:
>
> Hello,
>
> I'm not sure how to even search for the question I'm about to ask... I'm
> fairly new to this and I hope I'm using the right terminology.
>
> I'm going through some reframe subscriptions and trying to refactor them
> for performance. My problem is that I have "layer 2"/"extraction"
> subscriptions that loop through other subscriptions and do crazy things:
> slow?
>
> I'm not exactly sure what to do with these. I thought I should make
> "layer 3"/"materialized view" subscriptions out of them and have the crazy
> loops "subscribe" in the first function (the one subscribing to other
> reactions). But maybe I'm out to lunch.
>
> Here is an example of the "layer 2"/"extraction" subscription I'm dealing
> with:
>
> (rf/reg-sub
> :foo
> (fn [_ [_ x y z] _]
> (let [A @(subs/subscribe [:l x y])
> B @(subs/subscribe [:m y z])
> C @(subs/subscribe [:n x y z])
> D @(subs/subscribe [:o])]
> (into #{}
> (apply concat
> (for [a A
> b B
> :let [u (first C)]
> :when @(subs/subscribe [:p a u)]
> (for [c C
> :when (< 0 @(subs/subscribe [:q a u c]))]
> (list a u c))))))))
>
>
> Should I just make this a normal function (instead of registering a
> subscription) and coerce it to be a reaction? Would that be more efficient?
>
>
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.