1.0.5 • Published 3 years ago

samushi-global-settings v1.0.5

Weekly downloads
7
License
MIT
Repository
-
Last release
3 years ago

Vue plugin that helps to set and get data from vuex store

Installations

npm install samushi-global-settings

Usage

First you need to create vuex module with name global_settings and then to implement store in plugin

import GlobalSettings from 'samushi-global-settings'
import store from './store/index'

Vue.use(GlobalSettings, {store: store});

How to get settings

imagine your state and getters is like this

const state = {
    user: {
        name: "Sami Maxhuni",
        email: "samimaxhuni510@gmail.com"
    },
    banners: {
        show: true
    }
}

const getters = {
    getUserInfo: (state) => state.user,
    getBanners: (state) => state.banners
}

const mutations = {
    setUserInfo: (state, payload) => {
        state.user = Object.assign(state.user, payload);
    }   
}

when you want to get/set any value to the global settings you can do like this way example we do it this in component

mounted(){
    this.$globalSettings().set('setUserInfo.name', "Jusuf Maxhuni");    
},

computed: {
    
    username(){
        return this.$globalSettings().get('getUserInfo.name');
    },
    showBanner(){
        return this.$globalSettings().get('getBanners.show');
    }

}
1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

0.0.1

3 years ago