You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How is one supposed to set nested keyPaths in state mutations, given that mutations only receive state and not store and therefore by implication no $set() method?
Take for instance the following, in the examples:
[DECREMENT] (state) {
state.count--
}
.. which is fine if you need to set or replace a root level keyPath
... but what when you need to set something nested, eg:
Using Baobab, we could set a cursor to that point or using the $set () method we could specify the dot notation keypath ... but when we only have the state object ... ?
The text was updated successfully, but these errors were encountered:
So, here is what I decided to: I decided import the store into the mutations closure and use the _vm.$set() function to apply the changes to the keyPath.
import store from './index'
// ... other mutations stuff stuff ...
[SET] (state, keyPath, val) {
store._vm.$set('state.' + keyPath, val)
}
I don't know if this would be a recommended practice, but it does set the data and leave it all reactive, but perhaps more elegant means might be considered such as proxying the $set() method or something.
How is one supposed to set nested keyPaths in state mutations, given that mutations only receive state and not store and therefore by implication no $set() method?
Take for instance the following, in the examples:
.. which is fine if you need to set or replace a root level keyPath
... but what when you need to set something nested, eg:
What's the 'vue-y' way to change the value?
Using Baobab, we could set a cursor to that point or using the $set () method we could specify the dot notation keypath ... but when we only have the state object ... ?
The text was updated successfully, but these errors were encountered: