Follow us on: facebook twitter linkedin

TECHNOLOGY

VueX in Vue JS

Post by : John Deo
Post date: 2024-12-15 14:55:35

Read time : 5 minute
Total views: 194 times
hero-img

Whats Vuex?

VueX is state management library for Vue js.

 

Once created a component in Vue js under the data method we declare few object properties known as state.

Without Vuex state might be modify from one component to other component through emit slot and props. But ideal way is use any state management library.

 

Vuex structure

  1. State.
  2. Mutations.
  3. Actions.
  4. Getters.

State

State One of the important part for Vuex. Because this one is the entry point of vuex.Using this.$store.state.your_state_name state value can retrieve in component.

 

Mutations

Under the mutations we can declare method which one modify state value.Using this.$store.commit('your_function_name') we can called mutations in component.

 

Actions

Actions do same work as like mutations but bit differently.Actions can work asynchronously. Thats mean when we need complex logic or data fetching or time consuming task for modify state. Those task we may implement by actions. Using this.$store.dispatch('your_function_name') we called actions in component.

 

Getters

Getters return filter value from state.Using this.$store.getters('your_function_name') we called getters in component.

 

 

Share by:

Keep exploring

Read what excites, achieves and moves us Read what excites, achieves and moves us