Closed joshua1 closed 5 years ago
currently using a helper method like this . testing to see how efficient it is
const setState = async (moduleName, payload) => {
Object.keys(payload).forEach(key => {
store.dispatch(`${moduleName}/set/${key}`, payload[key])
})
}
Hi. @joshua1 Sorry I came back so late on this.
But this is not good practice. You should never do this to keep readability in your code. I would always recommend against this. 🙃
Not about readability and not a bug that needs fixing . More so , saying its not good practice is wrong. has nothing to do with readability.It's simply asking of a way to do object update that the library doesn't currently have.
I'm sorry. 😣 I didn't mean to upset you in any way.
I don't want to offer this as a feature but, I believe your wrapper function that you wrote should be good enough. If I had to implement it myself it would be a similar implementation. 😉
Sorry again and I hope you understand.
Sent with GitHawk
Can we have an additional feature where we call
store.set('module/',payload) or dispatch('set/moduleName/',payload)
to mutate the state object as a whole as opposed to mutating property after property. the internal implementation can just Object.assign the payload to the state. doing itemized set on an object can be a pain or take a lot more lines of code to write each time.key will be the / with no property name after . i will see about a PR , but might be quicker from your end