2.0.0-rc.3 • Published 10 years ago
vuex-promise v2.0.0-rc.3
VUEX-PROMISE
:two_hearts: A Promise Plugin for Vuex, compatible with 2.0.0-rc
Change Log
- 20160807 :warning: Breaking Changes
- modify meta structure
Usage
set plugin in store
import createPromise from 'vuex-promise'
export default new Vuex.Store({
strict: __DEV__,
...,
plugins: [createPromise({
debug: __DEV__,
status: {
PENDING: 'PROMISE_PENDING',
SUCCESS: 'PROMISE_SUCCESS',
FAILURE: 'PROMISE_FAILURE',
FINALLY: 'PROMISE_FINALLY'
},
silent: false
})]
})define module with getters and actions
import request from 'plato-request'
import {
GET_COMMITS
} from '../types'
import {
PROMISE_SUCCESS
} from '../constants'
const state = {
commits: null
}
const getters = {
commits: state => state.commits
}
const actions = {
getCommits ({ commit }, payload) {
commit(GET_COMMITS, request('{base}/commits?sha=', {
params: {
base: 'https://api.github.com/repos/crossjs/plato'
},
query: {
per_page: 3
},
headers: {
'Accept': 'application/vnd.github.v3+json'
}
}))
}
}
const mutations = {
[GET_COMMITS] (state, { payload, meta }) {
if (meta && meta.promise === PROMISE_SUCCESS) {
state.commits = payload
}
}
}
export default {
state,
getters,
actions,
mutations
}License
2.0.0-rc.3
10 years ago
2.0.0-rc.2
10 years ago
2.0.0-rc.1
10 years ago
1.0.2
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago
0.1.4
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.1
10 years ago
0.0.0
10 years ago