Fork me on GitHub
#beginners
<
2017-02-24
>
sova03:02:00

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

sova03:02:25

or general response headers n stuff?

val_waeselynck10:02:28

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

val_waeselynck10:02:00

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

fingertoe18:02:20

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?

byron-woodfork18:02:22

@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.

byron-woodfork18:02:43

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.

fingertoe18:02:30

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.

fingertoe18:02:27

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.

shaun-mahood23:02:47

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?

shaun-mahood23:02:00

Or is there a better way to do that?

seancorfield23:02:28

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

seancorfield23:02:51

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

seancorfield23:02:24

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.

shaun-mahood23:02:55

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 🙂