How to call a commit and dispatch asynchronously from same action?

vuex

#1

I want to perform an action only after mutation has done it’s job.

The mutation ( SOME_MUTATION ) is from same store and the action( test/testAction ) is from a module

someAction(context, data) {
    context.commit('SOME_MUTATION', data) // this should be committed first
    context.dispatch('test/testAction') // this action should be dispatched after the above commit
}

Note: I don’t know whether or not it is the default behaviour


#2

Why don’t you just ceate an action that calls the mutation then in the promise call the “testAction”?


#3

You mutation should be a synchronous job so it should be completed by the time you call your dispatch. If your mutation isn’t a quick and simple update then this is a sign that you should be using an action to handle the logic and only commit the mutation once the data is ready, in which case you can do as @miketimturner suggested.