0Pricing
Vue Academy · Lesson

Getters and Modules

Compute derived state and organize the store into modules.

Computed State with Getters

Sometimes you need derived state, like a filtered list or a count. A getter is the store equivalent of a computed property: it derives a value from state and caches the result until its dependencies change.

Defining a Getter

A getter is a function that receives state and returns a derived value.

getters: {
  completedTodos(state) {
    return state.todos.filter(t => t.done)
  }
}

All lessons in this course

  1. Vuex Fundamentals
  2. Mutations and Actions
  3. Getters and Modules
← Back to Vue Academy