Difference between computed() and computedFn() #3705
-
Heya, I want to solidify my understanding of const isEmpty = computedFn(
(props: complexProps): boolean => {
return lotsaWorkFunction(props);
}
); vs. function isEmpty(props: complexProps): boolean {
return computed(() => lotsaWorkFunction(props)).get();
}; Here's what I know:
Is there any other drawbacks for the Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
function isEmpty(props: complexProps): boolean {
return computed(() => lotsaWorkFunction(props)).get();
}; Every time you call |
Beta Was this translation helpful? Give feedback.
Maybe the part that isn't so obvious: If the
computedFn
is invalidated by anobservable
, it is recomputed with the previously passed params (the last one), if the result changes, caller is notified, re-runs, callsisEmpty
again, but very likely with the same set of params, so it won't re-computed twice.