update tutorial

This commit is contained in:
Yanick Champoux 2022-08-28 12:54:14 -04:00
parent 9255548326
commit c8bb1e5096

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 }]
}));
```