From 7ddc187f2b0e36da72ebeb3367629038d70b73de Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Sat, 1 Feb 2020 11:05:32 -0500 Subject: [PATCH] add documentation --- docs/updux.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/updux.md b/docs/updux.md index 4b8b0d1..d95ba2c 100644 --- a/docs/updux.md +++ b/docs/updux.md @@ -283,7 +283,9 @@ store.dispatch.addTodo(...); store.dispatch( actions.addTodo(...) ); ``` -## asDux +## Methods + +### asDux Returns a [ducks](https://github.com/erikras/ducks-modular-redux)-like @@ -291,7 +293,7 @@ plain object holding the reducer from the Updux object and all its trimmings. -## addMutation +### addMutation Adds a mutation and its associated action to the updux. If a local mutation was already associated to the action, @@ -303,3 +305,30 @@ conditionally run the subduxes mutations, check out [[subduxUpreducer]]. ```js updux.addMutation( add, inc => state => state + inc ); ``` + +### addAction + +```js +const action = updux.addAction( name, ...creatorArgs ); +const action = updux.addAction( otherActionCreator ); +``` + +Adds an action to the updux. It can take an already defined action creator, +or any arguments that can be passed to `actionCreator`. + +```js +import {actionCreator, Updux} from 'updux'; + +const updux = new Updux(); + +const foo = updux.addAction('foo'); +const bar = updux.addAction( 'bar', (x) => ({stuff: x+1}) ); + +const baz = actionCreator( 'baz' ); + +foo({ a: 1}); // => { type: 'foo', payload: { a: 1 } } +bar(2); // => { type: 'bar', payload: { stuff: 3 } } +baz(); // => { type: 'baz', payload: undefined } + +``` +