Dmitry Scheglov
Sep 4, 2018 · 1 min read

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 data are 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.

    Dmitry Scheglov

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade