Async data loading plugin for Vue.js
npm install vue-async-data-2Async data loading plugin for Vue.js

- this plugin is written in ES2015,
so recommend compile with babel/babel-polyfill.
`` bash`
npm install vue-async-data-2
` js`
// use as global plugin
import Vue from 'vue';
import { AsyncDataPlugin } from 'vue-async-data-2';
Vue.use(AsyncDataPlugin);
` js
// use as locally mixin
import { AsyncDataMixin } from 'vue-async-data-2';
export default {
mixins: [ AsyncDataMixin ],
}
`
` Loading... Error: {{ userNameError }} Hello {{ userName }} ! html
`
specify a function that returns Promise.
you can also specify a default value.
`js`
asyncData: {
userName () { // return promise
return new Promise((resolve) => {
resolve('risa');
})
},
userNameDefault: 'unknown', // default value
userNameLazy: false, // skip run at mount?
},
refresh data.
if name arg is specified, only that field is updated.
`js`
this.asyncReload('userName')
this.asyncReload()
global reload flag.
global error flag.
if resolve, set response.
if throw reject`, set error message.
set to true until there response.