Wraps a Vuex action so that it has the ability to handle both normal actions and promise-based async actions, commit mutations with the resolved payload created by payloadCreator. If no payload creator is passed, or if it's not a function, the identity function is used. The parameter type is considered as a mutation's name, it will be automatically triggered in the action.
Example:
let increment =createAction('INCREMENT',amount=> amount)
// same as
increment =createAction('INCREMENT')
expect(increment).to.be.a('function')
handleAction(handlers)
Wraps a mutation handler so that it can handle async actions created by createAction.
If a single handler is passed, it is used to handle both normal actions and success actions. (A success action is analogous to a resolved promise)
Otherwise, you can specify separate handlers for pending(), success() and error(). It's useful for tracking async action's status.
Example:
conststore=newVuex.Store({
state:{
obj:null
},
mutations:{
SINGLE:handleAction((state,mutation)=>{
state.obj= mutation
}),
CHANGE:handleAction({
pending(state,mutation){
state.obj= mutation
},
success(state,mutation){
state.obj= mutation
},
error(state,mutation){
state.obj= mutation
}
})
}
})
handleMutations(mutations)
Wraps a set of mutations with handleAction. The example above is the same as below