Explorar o código

Update getter docs (#601)

* Update getter docs

Add possibility to return functions in getters (https://github.com/vuejs/vuex/issues/598)

* more detailed description

more detailed description and removed function syntax
mudrz %!s(int64=8) %!d(string=hai) anos
pai
achega
4d796b0a1d
Modificáronse 1 ficheiros con 15 adicións e 0 borrados
  1. 15 0
      docs/en/getters.md

+ 15 - 0
docs/en/getters.md

@@ -61,6 +61,21 @@ computed: {
 }
 ```
 
+You can also pass arguments to getters by returning a function. This is particularly useful when you want to query an array in the store:
+```js
+getters: {
+  // ...
+  getTodoById: (state, getters) => (id) => {
+    return getters.todos.find(todo => todo.id === id)
+  }
+}
+```
+
+``` js
+store.getters.getTodoById(2) // -> { id: 2, text: '...', done: false }
+```
+
+
 ### The `mapGetters` Helper
 
 The `mapGetters` helper simply maps store getters to local computed properties: