1.0.5 • Published 3 years ago

thinking-data-provider v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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.

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.3

3 years ago

0.1.0

3 years ago