samushi-global-settings
v1.0.5
Published
Vue Plugin which make easy to seperate your global settings from vuex modules
Readme
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: "[email protected]"
},
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');
}
}