Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Allow Pathify-style commits in actions #79

Open
davestewart opened this issue Oct 2, 2019 · 4 comments
Open

[Feature Request] Allow Pathify-style commits in actions #79

davestewart opened this issue Oct 2, 2019 · 4 comments

Comments

@davestewart
Copy link
Owner

davestewart commented Oct 2, 2019

This post is asking whether you can do Pathify style commits in actions, and the answer is currently no:

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

@davestewart
Copy link
Owner Author

davestewart commented Oct 2, 2019

OK, PoC working for root and modules here:

Tasks:

  • make work for dynamically registered modules
  • make code cleaner than wrapping store with a function

@bkarlson
Copy link

bkarlson commented Oct 23, 2019

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!

@davestewart
Copy link
Owner Author

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!

@DarkLite1
Copy link

DarkLite1 commented Apr 25, 2020

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)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants