Accessing other getters

The second argument passed to a getter when called is the object that contains the other getters:

getters: {  ...  getCatPictures: state => state.pictures.filter(pic => isCat(pic))  getKittens: (state, getters) => {    return getters.getCatPictures().filter(cat => !isAdult(cat))  }}

In our recipe, we could call the euro getter to have some more derived data, like roughly how many houses we can buy with our Bitcoin given an average price of 150,000 euros:

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

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.