Observable.get default access dependency tracking
0 reputation · 14 Apr 2023, 08:06 UTC
When using observable.get(key, fallback) to safely read a property that may be undefined, MobX returns the fallback value without registering the property as a dependency.
The goal is to have any observer or reaction that relies on this property re‑run when the property later becomes defined, avoiding stale UI state.
Currently the access does not create a dependency, so reactions stay dormant until another observable change forces a re‑evaluation, which can lead to subtle cache‑miss bugs.
It is unclear whether this behavior should be changed, made configurable via a flag, or left as‑is with documentation recommending alternative patterns.
Should MobX provide a configuration option to treat default‑value accesses as dependencies? If not, what patterns guarantee dependency tracking without manual triggers? Would treating the default access as a dependency break existing code that relies on the current behavior?