repairearth / vuex-actions Goto Github PK
View Code? Open in Web Editor NEWAction utilities for Vuex, supports promise-based async actions.
License: MIT License
Action utilities for Vuex, supports promise-based async actions.
License: MIT License
defined an action use createAction
. invoke it in mounted
as this.getData().then(resilt => { })
result
is undefined.
In source code, function commitAsSuccess
and function dispatchAction
return undefined
Hi,
I have been trying to use vuex-actions within my store, but not on the main store, rather in its modules. I can't figure out, but the dispatch handler is called with the following type key: "[0]setPath"
.
Console error:
Error message: [vuex] unknown action type: [0]setPath
Stacktrace:
[vuex] unknown action type: [0]setPath
(anonymous function) -- build.umd.min.js:1:12484
dispatch -- vuex.js:242
o -- vex-action.min.js:1:1477
wrappedActionHandler -- vuex.js:451
(anonymous function) -- main.js:103 // my trigger for dispatch
Do you know if vuex-actions should work with modules? And if so, what am I missing?
Here's my store module implementation:
// import * as types from '../types'
// changing to vuex-action
import { createAction } from 'vuex-action'
const state = {
currentPath: ''
}
// const actions = {
// setPath ({ commit, state }, path) {
// if (state.currentPath !== path) {
// commit(types.CHANGE_URL_PATH, path)
// }
// }
// }
const setPath = createAction('setPath')
const actions = {
setPath: setPath
}
const getters = {
getCurrentPathTransition: state => {
let trans = ''
switch (state.currentPath) {
case '':
case '/':
trans = 'slide-right'
break
case 'area':
trans = 'slide-left'
break
default:
break
}
return trans
}
}
const mutations = {
// [types.CHANGE_URL_PATH] (state, path) {
// state.currentPath = path
// },
[setPath] (state, path) {
state.currentPath = path
}
}
export default {
state,
mutations,
getters,
actions
}
Thanks a lot!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.