New to Vuex and Vue in general, I'm having a hard time getting my head around how Vuex is used "reactively". Co-worker tried explaining and didn't do a very good job or I'm just dense, but he was saying the store can be observed for reactive updates to repaint your UI.
I think I get the idea behind computed properties, like it wraps the properties used with it's function body in a callback or something and will re-evaluate the whole function on any of those changes. How does Vuex play into this? I see examples like with a store's state, getters, and mutations
state: {
user: null,
role: null
},
getters: {
getUser: state => state.user,
getRole: state => state.role,
},
mutations: {
setUser: ({state}, user) => {
state.user = user
},
setRole: ({state}, role) => {
state.user = role
}
}
I'm just not bridging the gap between that and a component being able to make UI updates. Do I set up methods or something like the observable callbacks I mentioned?
methods: {
getUserFromStore () {
return this.$store.getters.getUser
}
}
I need to manually call this so it goes against reactivity. Do I need the mapper functions?