I really want to join your team :)
I missed option to wrap with proxies on reading — shame on me …
However, I’ve just reviewed pull where json-api-formated payload is pushed to the redux-state. It is something like this:
[
{
id: '0000000-0000-00000-000000',
type: 'contacts',
attributes: {
name: '...',
email: '...',
...
},
referencies: {
user: {
data: {
id: '0000000-0000-00000-000000',
type: 'users',
},
},
....
}
},
{
id: '0000000-0000-00000-000000',
type: 'contacts',
attributes: {
name: '...',
email: '...',
...
},
referencies: {
user: {
data: {
id: '0000000-0000-00000-000000',
type: 'users',
},
},
....
}
},
...
]So, we can be sure that we will wrap with proxies all array items, and all nested fields:attributes, user, and data.
It is an anti-pattern for any approach, including redux, MobX, vuex etc. But I guess many of developers do not keep their state as flat as possible (especially, when he/she doesn’t need to care about modification of complex state).
By the way, VueJS uses observer, considering:
When this data changes, the view will re-render. It should be noted that properties in
dataare only reactive if they existed when the instance was created.
See Vue Instance.
So, Vue wraps with getters and setter all nested fields, and decorates mutating array.prototype methods for values that are arrays.
