Passing an argument

If a getter returns a function with an argument, that argument will be the argument of the getter:

getters: {  ...  getWorldWonder: state => nth => state.worldWonders[nth]}

In our recipe, a practical example could specify the average cost of a house in the getter from the previous paragraph:

const store = new Vuex.Store({  state: {    bitcoin: 600,    rate: 1000  },  getters: {    euro: state => state.bitcoin * state.rate,    houses: (state, getters) => averageHousePrice => {      return getters.euro() / averageHousePrice    }})

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.