thinking-data-provider
v1.0.5
Published
data provider
Downloads
2
Readme
thinking-data-provider
data provider
Install
npm i thinking-data-provider
Use in js
import { createDataProvider } from 'thinking-data-provider';
const stateQuery = createDataProvider({
// axios or other Promise
action: vars => axios.get('/posts', { params: vars }),
variables: {
page: 1,
limit: 10,
},
initData: {
list: [],
total: 0,
},
update: fullData => fullData.list || [],
extra: {},
skip: true,
});
Use in vue
// in entry
import { createVuePlugin } from 'thinking-data-provider';
import Vue from 'vue';
Vue.use(createVuePlugin());
// in component
export default {
data() {
return {
stateQuery: this.$createDataProvider({
// axios or other Promise
action: vars => this.$axios.get('/posts', { params: vars }),
variables: {
page: 1,
limit: 10,
},
initData: {
list: [],
total: 0,
},
update: fullData => fullData.list || [],
extra: {},
skip: true,
}),
};
},
};
Detail usage
Detail usage and more technical thoughts is coming soon.