Fork me on GitHub

Is it possible to read ring session variables in client-side clojurescript?


or general response headers n stuff?


@sova certainly not session variables, that would be a security breach


response headers should be accessible, but how you access them depends on your http library


If I get a json input to my function with 20 or so nested items, is there any disadvantage to passing that whole thing to the functions down the line rather than pulling out the 4 or 5 items I may be interested in and only passing those details? Its all already in memory anyway, correct?


@fingertoe I don't believe there's a disadvantage to that.. However, from a design perspective, I normally try and only pass data to a function that plans to use all/most of it. If the function is only concerned with a few pieces of data from a larger dataset, I'd just pass in those few pieces instead of the entire thing.


That of course, is my opinion without a lot of insight to the problem. It could be useful to pass in the entire dataset. It simply depends.


to be a bit more specific, the incoming json is an Alexa request. I am thinking I will do a defmulti to dispactch on the particular function the user is asking for — I may or may not know what those functions are going to need.


In my intial app, I was parsing the data for each function and passing exactly what it needed, but then I have to engineer each function up front… rather than engineering it in one place down stream.


If I'm filtering data with a bunch of predicates using something like (filter #(and (p1 %) (p2 %) (p3 %)) coll), does the order of the predicates make any difference to performance?


Or is there a better way to do that?


Well, they’ll be lazily checked from left to right and only all checked if they’re all true.


So if most of your sequence satisfies all three predicates, it likely won’t matter.


However, if most of your sequence fail at least one of those predicates, you’ll get better performance putting that more-often-failing predicate first in the and.


Thanks 🙂 Probably the furthest thing from a bottle-neck but if I have to pick an order it may as well be the best one 🙂