From c8bb1e5096055895fd0ac08dca5fa5350f6d1fd8 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Sun, 28 Aug 2022 12:54:14 -0400 Subject: [PATCH] update tutorial --- docs/tutorial.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/tutorial.md b/docs/tutorial.md index d766735..e1a9e3e 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -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 }] +})); +```