Skip to content

Commit 9f1f69f

Browse files
author
Ray Foss
authored
Clarify api change inline
should be clear, even without coffee
1 parent f873413 commit 9f1f69f

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,12 @@ store.dispatch('todos/create', newTodo)
290290
```
291291

292292

293-
#### `update([id, data, params])`
293+
#### `update(paramArray)`
294294
Update (overwrite) a record.
295-
- `id {Number|String}` - the `id` of the existing record being requested from the API server.
296-
- `data {Object}` - the data that will overwrite the existing record
297-
- `params {Object}` - An object containing a `query` object.
295+
- `paramArray {Array}` - array contailning the three parameters update takes.
296+
- `id {Number|String}` - the `id` of the existing record being requested from the API server.
297+
- `data {Object}` - the data that will overwrite the existing record
298+
- `params {Object}` - An object containing a `query` object.
298299

299300
```js
300301
let data = {id: 5, description: 'write your tests', completed: true}
@@ -303,11 +304,26 @@ let params = {}
303304
store.dispatch('todos/update', [1, data, params])
304305
```
305306

306-
#### `patch([id, data, params])`
307+
Alternatively in a Vue component
308+
```
309+
import { mapActions } from 'vuex'
310+
export default {
311+
methods: {
312+
...mapActions('todos', [ 'update' ]),
313+
addTodo () {
314+
let data = {id: 5, description: 'write your tests', completed: true}
315+
this.update([1, data, {}])
316+
}
317+
}
318+
}
319+
```
320+
321+
#### `patch(paramArray)`
307322
Patch (merge in changes) one or more records
308-
- `id {Number|String}` - the `id` of the existing record being requested from the API server.
309-
- `data {Object}` - the data that will be merged into the existing record
310-
- `params {Object}` - An object containing a `query` object.
323+
- `paramArray {Array}` - array contailning the three parameters patch takes.
324+
- `id {Number|String}` - the `id` of the existing record being requested from the API server.
325+
- `data {Object}` - the data that will be merged into the existing record
326+
- `params {Object}` - An object containing a `query` object.
311327

312328
```js
313329
let data = {description: 'write your tests', completed: true}

0 commit comments

Comments
 (0)