Skip to content

Latest commit

 

History

History
51 lines (41 loc) · 1.06 KB

StateManagement.md

File metadata and controls

51 lines (41 loc) · 1.06 KB

STATE MANAGEMENT (VUEX)

To Enable Namespacing with Vuex add namespace in store module object

example go to

./resources/assets/js/vuex/store/modules/auth.js

export default {
  namespaced: true, // <!--- you need to Enable it By Adding this Key and value
  state,
  getters,
  actions,
  mutations
}

Also add new modules @ ./resources/assets/js/vuex/store/index.js

import users from './modules/users'
import auth from './modules/auth'
// import here Other Modules @ ./modules/*

export default new Vuex.Store({
  modules: {
    users,
    auth
   // add modules here
  }
})

Maping With Vuex in Components with Module Namespacing

computed: {
  ...mapState('users', { //<!-- Your NameSpace Module Should Be Added Here
    firstName: state => state.firstName,
    lastName: state => state.lastName,
    email: state => state.email
  })
},
methods: {
  ...mapActions('auth', [ //<!-- Your NameSpace Module Should Be Added Here
    'login'
  ])
}