update tutorial

typescript
Yanick Champoux 2022-08-28 12:54:14 -04:00
parent 9255548326
commit c8bb1e5096
1 changed files with 12 additions and 0 deletions

View File

@ -60,3 +60,15 @@ Once an action is defined, its creator is accessible via the `actions` accessor.
console.log( todosDux.actions.addTodo('write tutorial') );
// prints { type: 'addTodo', payload: 'write tutorial' }
```
### Adding a mutation
Mutations are the reducing functions associated to actions. They
are defined via the `setMutation` method:
```js
todosDux.setMutation( 'addTodo', description => ({next_id: id, todos}) => ({
next_id: 1 + id,
todos: [...todos, { description, id, done: false }]
}));
```