Hi Mike, yep, that is what I meant by "> I can work around this - the subscription code typically delegates to a 'plain' defn so I can retrieve the data from the db and call the same defn, but sometimes that jars a bit." :).
On 27 March 2015 at 20:47, Mike Thompson <[email protected]> wrote: > On Saturday, March 28, 2015 at 7:36:26 AM UTC+11, Colin Yates wrote: >> I have various chunks of reference data, say a tree or a list of _all_ (i.e. >> active and historical) entities. I then have various subscriptions which >> refine that view, for example: >> - only active >> - only active but including a given id >> >> In the handler I sometimes need access to this data, but according to the >> re-frame doc: >> >> "Rules: >> >> components never source data directly from app-db, and instead, they use a >> subscription. >> subscriptions are only ever used by components (they are never used in, say, >> event handlers)." >> >> I can work around this - the subscription code typically delegates to a >> 'plain' defn so I can retrieve the data from the db and call the same defn, >> but sometimes that jars a bit. >> >> The fact it is useful for me to do something not only discouraged but >> actively against the rules makes me question my design somewhat; what is the >> rationale for not allowing an event handler to view a subscription? Am I >> wrong in viewing a subscription as merely a view on the data in which case I >> don't see the danger... >> >> I get that components should be divorced from the structure of the DB and >> event handlers necessarily need to know the structure but I see a >> subscriptions as more than just structure - it sometimes applies >> transformations that I would want to re-use. >> >> Thanks! > > My suggestion: factor out the reusable code (like "only-active") into a > function. Then you can wrap that function in a subscription OR use the > function directly in the handlers. > > -- > Mike > > > > -- > 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. -- 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.
