1.0.11 • Published 4 years ago

vuex-no-map v1.0.11

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

vuex-no-map

npm npm

This plugin allows to omit using mapState, mapGetters, mapMutations, mapActions And thus reduce amount of code.

For example, instead of writing this code (consider having counter store module):

<template>
    <div>{{ count }}</div>
    <div>{{ getFormattedCount }}</div>
    <button @click="INCREMENT">+</button>
    <button @click="DECREMENT">-</button>
    <button @click="callApi">call</button>
</template>

<script>
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex';

export default {
    name: 'TestComponent',
    computed: {
        ...mapState('counter', ['count']),
        ...mapGetters('counter', ['getFormattedCount'])
    },
    methods: {
        ...mapMutations('counter', ['INCREMENT', 'DECREMENT']),
        ...mapActions('counter', ['callApi'])
    }
}
</script>

We could write this:

<template>
    <div>{{ counter_count }}</div>
    <div>{{ counter_getFormattedCount }}</div>
    <button @click="counter_INCREMENT">+</button>
    <button @click="counter_DECREMENT">-</button>
    <button @click="counter_callApi">call</button>
</template>

<script>
export default {
    name: 'TestComponent'
}
</script>

Usage:

import Vue from 'vue';
import Vuex from 'vuex';
import VuexNoMap from 'vuex-no-map';

const store = new Vuex.Store({
    // store options here
});

Vue.use(VuexNoMap, { Vuex, store });
1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago