-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
Description
Intended outcome: If I create a computed value and access it twice, it should only compute its value once (even if there is no reaction that depends on its value). This is the behavior of other state management libraries and of computed values in the signals standard proposal, so new users would likely expect this of MobX.
Actual outcome: Untracked computed values recompute the value each time the value is accessed.
How to reproduce the issue:
const computedValue = computed(() => console.log('computed'));
setInterval(() => computedValue.get(), 100);
// Should only log oncePassing { keepAlive: true } fixes the issue, but shouldn't that be the default behavior? With #1799 I don't see any downsides to having all computed values be keepAlive.
Note that this would likely be a semver major change.
Versions
6.13.7