I understand that you can provide parameters when subscribing to something, but
I am unsure when it is idiomatic to do so. The example in the documentation is
for a static value (the number of results), but what about if those parameters
change frequently.
For example, let's say I have a subscription which renders a hierarchy. Each
node in that hierarchy may be archived? s/Bool. When I want to render that
hierarchy I need to ensure that I can see all non-archived nodes _and_ the node
that I have currently selected regardless of whether it is archived.
I could achieve this with something like:
(register-sub
:some-reference-data/hierarchy
(fn [db [_ current-id]]
(let [tree (load-hierarchy-with-node current-id)] (reaction tree))))
This means I will have many invocations of the above (subscribe
[:some-reference-data/hierarchy my-id]) for many different ids.
On the other hand, I could have a single subscription for the whole hierarchy
and prune the tree outside the subscription.
Which is more idiomatic?
On a related note, in a component, is it OK to do [:div (do-something-with
@(subscribe [:some-reference-data/hierarchy (:id node))) or is a memory leak
waiting to happen?
Thanks!
--
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 http://groups.google.com/group/clojurescript.