vuex-pathify
vuex-pathify copied to clipboard
[Feature Request] Allow Pathify-style commits in actions
This post is asking whether you can do Pathify style commits in actions, and the answer is currently no:
- https://stackoverflow.com/questions/58196573/sub-property-write-commit-withing-store-actions-using-vuex-pathify-make-mutation
However, a quick monkey patch proves it might be possible to intercept the native commits and do something with them:
var commit = store.commit
store.commit = function (...args) {
console.log('COMMITTING', ...args)
commit(...args)
}
COMMITTING locateList/id 51ff8a16-9f2b-41da-93cf-a07945a46318 undefined
So with that in mind, it might be possible to detect @
characters and do a Pathify style set()
instead.
Another option would be wrapping this in the existing commit helper, or even adding a helper to build and pass Payloads, like this demo
- https://github.com/davestewart/vuex-pathify/issues/80
OK, PoC working for root and modules here:
- https://twitter.com/dave_stewart/status/1179527236371787776
Tasks:
- [ ] make work for dynamically registered modules
- [ ] make code cleaner than wrapping store with a function
would be great to have this released, as I was going in circles in google trying to keep my code simple yet my state nested. Seems like with Vuex you cannot have both. Pathify to the rescue!
Hey @bkarlson - it's not a priority for me now (I have other things I want to spend my ODD dev time on) so don't hold your breath!
Yeah, I also ended up here thinking that this would've been a really cool addition to the library. Shame you're no longer into Vuex anymore if I read it correctly. Classes are indeed easier for OO devs but I'm more of a functional programming type of person. Anyway, thanks again for this amazing library. It already saved me a lot of time and effort in writing pointless setters
.
Maybe I'll just use your previous suggestion in another post:
import store from '../index'
const actions = {
foo({commit}, value) {
store.set('page@status', value)
}
}