michaelolof / vuex-class-component

A Type Safe Vuex Module or Store Using ES6 Classes and ES7 Decorators written in TypeScript.
217 stars 21 forks source link

[Feature] Deep/nested mutations #54

Open SaphuA opened 5 years ago

SaphuA commented 5 years ago

Do you think it would be possible to add support for deep mutations to support state with nested fields? I'm sure it won't be an easy task, but it would sure be awesome! Nested fields are supported in that they are reactive, but obvously there's no mutation associated with them.

Glandos commented 4 years ago

I think this is not so difficult based on the existing code. Automatic mutation is declared in the proxy, and this is already recursive, for each submodule for now. But I manually tried to called the internal mutator with a composed path (stateVar.prop) and it worked like a charm.

I guess the createGettersAndMutationProxyFromState can be called recursively on each enumerable property?