Vuex Flashcards
What is Vuex?
Vuex is a library to manage global state.
or
Vuex helps manage Data that affects multiple components over the entire app
For example.
- Auth
- Shopping cart items
Why is Vuex worth using?
Vuex affects your codebase:
L: less error-prone
A: avoid fat components
R: reduces unpredictably
by
C: clearly defined data flow
O: Outsourced state management
P: Predictable state management / flow
What do mutations do?
changes values in a state.
What do getters do?
Returns values from the a state
it is where you ‘get a value’. from the state.
you can manipulate it here , and it won’t change I the state. i.e multiplier the value by 3
it will then send the data onward.
method
what do actions do?
components should trigger acoutions
actions should trigger mutations
note! components should not trigger mutations
Used for asynrous code.
method
What are the core components that are used in Vuex
What is the core file structure.
You have
G: Getters
A: Actions
M: Mutations
S: State
Folder structure.
Store
index
Actions
mutations
How do you interact witt the store
$store.state.data
what is a payload
it can be aything , number / object , it just represent data that has been passed on a commit.
what is a payload
it can be aything , number / object , it just represent data that has been passed on a commit.
what does _ do in an argument ( _, something)
it’s an indication that that you recognise that it has a argument that you do not want to use it
for example not needing the store on a getter