appbaseio/reactivesearch

View on GitHub
packages/vue/src/components/Provider.js

Summary

Maintainability
A
0 mins
Test Coverage
export default {
    name: 'Provider',
    props: {
        store: {
            type: Object,
            required: true,
            validator(store) {
                if (!store.dispatch && !store.subscribe && !store.getState) {
                    throw new Error(
                        '[reactivesearch-vue] - store provided is not a valid redux store'
                    );
                }
                return true;
            }
        }
    },
    provide() {
        return {
            $$store: this.store
        };
    },
    render(h) {
        if (this.$slots.default.length > 1) {
            return h('div', this.$slots.default);
        }
        return this.$slots.default[0];
    }
};