Replies: 1 comment
-
You're just confused by const o = {};
console.log(o);
o.a = 5;
// inspecting `o` in dev tools displays `{ o: 5 }` So in some sense the autorun would have to see in the future, which would be quite cool, but we are not there yet. The
Could be the case, not sure atm. I think the reasoning could be that observing |
Beta Was this translation helpful? Give feedback.
-
I like mobx. I built a complex form handler with it in 2021. Coming back to it, I've noticed unexpected behavior that I imagine throws many people off and is probably one of the reasons mobx is not more popular. I understand this is a byproduct of the behavior of proxies, but if you look at something like vue, they manage the
push
well (https://codepen.io/cfjedimaster/pen/GObpZM) . I imagine very few people who initially put a shallow observe on an array intended it to only observe a full swap (reference change).Shallow Array Unexpected Behavior
This last bit surprised me when I found a component observing x.length re running when x.length did not change.
Deep Array Unexpected Behavior
I wondered whether deep array observable would solve some of these problems. But, it results in more unexpected behavior.
Most annoying, observing
x.length
triggers on an element change regardless of whetherx.length
changes.Popularity and Changes
Reactivity with proxies is somewhat complex and that limits audience. Vue deals with this by hiding some things. For instance, in the https://codepen.io/cfjedimaster/pen/GObpZM example, the
methods.checkForm
is a sort of mobx action, where the errors observable changes only cause a single re-render. The vue developer doesn't need to know that.However, when you add on to the complexity unexpected behavior, like x.push handling, observing x.length, etc, you get even more of a fall off of audience.
Years ago when I started with mobx, I had a lot of frustration before I found
toJS
, which should be very apparent in the docs.Any way, I've not considered how to solve these things until there is an acknowledgement that they are problems and should be solved.
Beta Was this translation helpful? Give feedback.
All reactions