4 ms·
One issue with the sample code. In the runQuery snippet, you call .set(...) on queryCache. But since it is an instance of Immutable.Map(), without re-assigning
by jhgg 11y ago
One issue with the sample code. In the runQuery snippet, you call .set(...) on queryCache. But since it is an instance of Immutable.Map(), without re-assigning it to queryCache, it would really have no effect.
queryCache.set(query, results);
vs
queryCache = queryCache.set(query, results);
- jlongster 11y agoThanks, fixed!
- Touche 11y agoMixing immutably with mutation (using let) seems weird to me. If you want to go immutable to make understanding your app easier then great, but use const throughout then.
- elros 11y agoWhy? `const` isn't that much immutable than `let` is. For any reference type that's bound to a variable with `const`, you can mutate it without getting errors. This was very confusing to me at first, even though I understand the mechanics behind it. const a = {} // That's OK: a.a = 1 // That's not OK: a = 1 While I don't disagree with you on your point, one could easily create the counter-point that by using `const` you're implying something that's not true.
- kansface 11y agoThe translation to C would be * const, not const *. Const is strictly better than let because it prevents a certain class of bugs - use it everywhere possible instead of let/var.