computedFn: Structural Comparer for Parameters? #3703
Replies: 3 comments 1 reply
-
It uses Map to locate the entry, so the comparator is always SameValueZero. |
Beta Was this translation helpful? Give feedback.
-
Thanks so much @urugator for the quick response. Does that mean that
In the example above, would If this is the case, is there any way to have Thanks! |
Beta Was this translation helpful? Give feedback.
-
Ah, I see. Thank you for the response, @urugator . So in summary:
Thanks a lot for the help, urugator! I appreciate it. Best, |
Beta Was this translation helpful? Give feedback.
-
Hiya folks!
Name's Kevin Lee, I work in Microsoft and MobX is glorious.
I have a question. I've started to find scenarios where I need to use
comparer.shallow
incomputed
and it's going great. When it comes tocomputedFn
, is there a similar way to say: "HeycomputedFn
, please shallow-compare / structural-compare the parameters of the function to get a cache hit"? Or am I misunderstanding and computedFn already does that? (e.g. if the computedFn's parameter list is not simple, and is a structural object, will computedFn work?)As in, my understanding is: ComputedFn will look at the params (e.g. two numbers) and, if they're the same and the result hasn't been recomputed, they'll return the same cached value. However, I'm wondering about the parameters-being-same-check. Can that ever be shallow/structurally compared, or is it always ref-compared? There's a few scenarios where we pass in some complex properties, wondering if that's possible to be computedFn'd.
Thanks so much,
Kevin Lee
Beta Was this translation helpful? Give feedback.
All reactions