updux/docs/classes/updux.html
Yanick Champoux 057226dfd1 compile
2019-11-06 19:07:06 -05:00

812 lines
47 KiB
HTML

<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Updux | updux</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base="..">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="../index.html" class="title">updux</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
<input type="checkbox" id="tsd-filter-only-exported" />
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="../globals.html">Globals</a>
</li>
<li>
<a href="updux.html">Updux</a>
</li>
</ul>
<h1>Class Updux&lt;S&gt;</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel tsd-comment">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p><code>Updux</code> is a way to minimize and simplify the boilerplate associated with the
creation of a <code>Redux</code> store. It takes a shorthand configuration
object, and generates the appropriate reducer, actions, middleware, etc.
In true <code>Redux</code>-like fashion, upduxes can be made of sub-upduxes (<code>subduxes</code> for short) for different slices of the root state.</p>
</div>
</div>
</section>
<section class="tsd-panel tsd-type-parameters">
<h3>Type parameters</h3>
<ul class="tsd-type-parameters">
<li>
<h4>S</h4>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Store&#39;s state type. Defaults to <code>any</code>.</p>
</div>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<span class="target">Updux</span>
</li>
</ul>
</section>
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Constructors</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-constructor tsd-parent-kind-class"><a href="updux.html#constructor" class="tsd-kind-icon">constructor</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Properties</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-property tsd-parent-kind-class"><a href="updux.html#groommutations" class="tsd-kind-icon">groom<wbr>Mutations</a></li>
<li class="tsd-kind-property tsd-parent-kind-class"><a href="updux.html#initial" class="tsd-kind-icon">initial</a></li>
<li class="tsd-kind-property tsd-parent-kind-class"><a href="updux.html#subduxes" class="tsd-kind-icon">subduxes</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Accessors</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="updux.html#actions" class="tsd-kind-icon">actions</a></li>
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="updux.html#asdux" class="tsd-kind-icon">as<wbr>Dux</a></li>
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="updux.html#createstore" class="tsd-kind-icon">create<wbr>Store</a></li>
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="updux.html#middleware" class="tsd-kind-icon">middleware</a></li>
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="updux.html#mutations" class="tsd-kind-icon">mutations</a></li>
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="updux.html#reducer" class="tsd-kind-icon">reducer</a></li>
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="updux.html#subduxupreducer" class="tsd-kind-icon">subdux<wbr>Upreducer</a></li>
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="updux.html#upreducer" class="tsd-kind-icon">upreducer</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Methods</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><a href="updux.html#addmutation" class="tsd-kind-icon">add<wbr>Mutation</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Constructors</h2>
<section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class">
<a name="constructor" class="tsd-anchor"></a>
<h3>constructor</h3>
<ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">new <wbr>Updux<span class="tsd-signature-symbol">(</span>config<span class="tsd-signature-symbol">?: </span><a href="../globals.html#upduxconfig" class="tsd-signature-type">UpduxConfig</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="updux.html" class="tsd-signature-type">Updux</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L109">updux.ts:109</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> config: <a href="../globals.html#upduxconfig" class="tsd-signature-type">UpduxConfig</a><span class="tsd-signature-symbol"> =&nbsp;{}</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="updux.html" class="tsd-signature-type">Updux</a></h4>
</li>
</ul>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="groommutations" class="tsd-anchor"></a>
<h3>groom<wbr>Mutations</h3>
<div class="tsd-signature tsd-kind-icon">groom<wbr>Mutations<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">function</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L99">updux.ts:99</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Function that can be provided to alter all local mutations of the updux
(the mutations of subduxes are left untouched).</p>
</div>
<p>Can be used, for example, for Immer integration:</p>
<pre><code><span class="hljs-keyword">import</span> Updux <span class="hljs-keyword">from</span> <span class="hljs-string">'updux'</span>;
<span class="hljs-keyword">import</span> { produce } <span class="hljs-keyword">from</span> <span class="hljs-string">'Immer'</span>;
<span class="hljs-keyword">const</span> updux = <span class="hljs-keyword">new</span> Updux({
<span class="hljs-attr">initial</span>: { <span class="hljs-attr">counter</span>: <span class="hljs-number">0</span> },
<span class="hljs-attr">groomMutations</span>: <span class="hljs-function"><span class="hljs-params">mutation</span> =&gt;</span> <span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> produce( mutation(...args) ),
<span class="hljs-attr">mutations</span>: {
<span class="hljs-attr">add</span>: <span class="hljs-function">(<span class="hljs-params">inc=<span class="hljs-number">1</span></span>) =&gt;</span> <span class="hljs-function"><span class="hljs-params">draft</span> =&gt;</span> draft.counter += inc
}
});
</code></pre><p>Or perhaps for debugging:</p>
<pre><code><span class="hljs-keyword">import</span> Updux <span class="hljs-keyword">from</span> <span class="hljs-string">'updux'</span>;
<span class="hljs-keyword">const</span> updux = <span class="hljs-keyword">new</span> Updux({
<span class="hljs-attr">initial</span>: { <span class="hljs-attr">counter</span>: <span class="hljs-number">0</span> },
<span class="hljs-attr">groomMutations</span>: <span class="hljs-function"><span class="hljs-params">mutation</span> =&gt;</span> <span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> <span class="hljs-function"><span class="hljs-params">state</span> =&gt;</span> {
<span class="hljs-built_in">console</span>.log( <span class="hljs-string">"got action "</span>, args[<span class="hljs-number">1</span>] );
<span class="hljs-keyword">return</span> mutation(...args)(state);
}
});
</code></pre>
</div>
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal tsd-parent-kind-property">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>mutation<span class="tsd-signature-symbol">: </span><a href="../globals.html#mutation" class="tsd-signature-type">Mutation</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#mutation" class="tsd-signature-type">Mutation</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>mutation: <a href="../globals.html#mutation" class="tsd-signature-type">Mutation</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="../globals.html#mutation" class="tsd-signature-type">Mutation</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</li>
</ul>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="initial" class="tsd-anchor"></a>
<h3>initial</h3>
<div class="tsd-signature tsd-kind-icon">initial<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">S</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L62">updux.ts:62</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Default initial state of the reducer. If applicable, merges the
initial states of <code>config</code> and <code>subduxes</code>, with <code>config</code> having
precedence.</p>
</div>
<p>If nothing was provided, defaults to an empty object.</p>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="subduxes" class="tsd-anchor"></a>
<h3>subduxes</h3>
<div class="tsd-signature tsd-kind-icon">subduxes<span class="tsd-signature-symbol">:</span> <a href="../globals.html#dictionary" class="tsd-signature-type">Dictionary</a><span class="tsd-signature-symbol">&lt;</span><a href="updux.html" class="tsd-signature-type">Updux</a><span class="tsd-signature-symbol">&gt;</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L53">updux.ts:53</a></li>
</ul>
</aside>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Accessors</h2>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="actions" class="tsd-anchor"></a>
<h3>actions</h3>
<ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> actions<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#dictionary" class="tsd-signature-type">Dictionary</a><span class="tsd-signature-symbol">&lt;</span><a href="../globals.html#actioncreator" class="tsd-signature-type">ActionCreator</a><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L162">updux.ts:162</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Action creators for all actions defined or used in the actions, mutations, effects and subduxes
of the updux config.</p>
</div>
<p>Non-custom action creators defined in <code>actions</code> have the signature <code>(payload={},meta={}) =&gt; ({type,
payload,meta})</code> (with the extra sugar that if <code>meta</code> or <code>payload</code> are not
specified, the key is not present in the produced action).</p>
<p>If the same action appears in multiple locations, the precedence order
determining which one will prevail is</p>
<pre><code>actions generated <span class="hljs-keyword">from</span> mutations/effects &lt; non-<span class="hljs-keyword">custom</span> subduxes actions &lt;
<span class="hljs-keyword">custom</span> subduxes actions &lt; <span class="hljs-keyword">custom</span> actions</code></pre>
</div>
<h4 class="tsd-returns-title">Returns <a href="../globals.html#dictionary" class="tsd-signature-type">Dictionary</a><span class="tsd-signature-symbol">&lt;</span><a href="../globals.html#actioncreator" class="tsd-signature-type">ActionCreator</a><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="asdux" class="tsd-anchor"></a>
<h3>as<wbr>Dux</h3>
<ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> asDux<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#dux" class="tsd-signature-type">Dux</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L258">updux.ts:258</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Returns a
<a href="https://github.com/erikras/ducks-modular-redux">ducks</a>-like
plain object holding the reducer from the Updux object and all
its trimmings.</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <a href="../globals.html#dux" class="tsd-signature-type">Dux</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="createstore" class="tsd-anchor"></a>
<h3>create<wbr>Store</h3>
<ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> createStore<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">function</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L241">updux.ts:241</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Same as doing</p>
</div>
<pre><code>import { createStore, applyMiddleware } <span class="hljs-keyword">from</span> <span class="hljs-string">'redux'</span>;
const { initial, reducer, middleware, actions } = updox(<span class="hljs-built_in">..</span>.);
const store = createStore( initial, reducer, applyMiddleware(middleware) );
<span class="hljs-keyword">for</span> ( let<span class="hljs-built_in"> type </span><span class="hljs-keyword">in</span> actions ) {
store.dispatch[type] = (<span class="hljs-built_in">..</span>.args) =&gt; {
store.dispatch(actions[type](<span class="hljs-built_in">..</span>.args))
};
}</code></pre><p>So that later on you can do</p>
<pre><code>store.dispatch.addTodo<span class="hljs-comment">(...)</span>;
<span class="hljs-comment">// still work</span>
store.dispatch<span class="hljs-comment">( actions.addTodo(...)</span> );</code></pre>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">function</span></h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#storewithdispatchactions" class="tsd-signature-type">StoreWithDispatchActions</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<h4 class="tsd-returns-title">Returns <a href="../globals.html#storewithdispatchactions" class="tsd-signature-type">StoreWithDispatchActions</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="middleware" class="tsd-anchor"></a>
<h3>middleware</h3>
<ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> middleware<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#upduxmiddleware" class="tsd-signature-type">UpduxMiddleware</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L140">updux.ts:140</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A middleware aggregating all the effects defined in the
updux and its subduxes. Effects of the updux itself are
done before the subduxes effects.
Note that <code>getState</code> will always return the state of the
local updux. The function <code>getRootState</code> is provided
alongside <code>getState</code> to get the root state.</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <a href="../globals.html#upduxmiddleware" class="tsd-signature-type">UpduxMiddleware</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="mutations" class="tsd-anchor"></a>
<h3>mutations</h3>
<ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> mutations<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#dictionary" class="tsd-signature-type">Dictionary</a><span class="tsd-signature-symbol">&lt;</span><a href="../globals.html#mutation" class="tsd-signature-type">Mutation</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L191">updux.ts:191</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Merge of the updux and subduxes mutations. If an action triggers
mutations in both the main updux and its subduxes, the subduxes
mutations will be performed first.</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <a href="../globals.html#dictionary" class="tsd-signature-type">Dictionary</a><span class="tsd-signature-symbol">&lt;</span><a href="../globals.html#mutation" class="tsd-signature-type">Mutation</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="reducer" class="tsd-anchor"></a>
<h3>reducer</h3>
<ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> reducer<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">function</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L182">updux.ts:182</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>A Redux reducer generated using the computed initial state and
mutations.</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">function</span></h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>state<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span>, action<span class="tsd-signature-symbol">: </span><a href="../globals.html#action" class="tsd-signature-type">Action</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">S</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>state: <span class="tsd-signature-type">S</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span></h5>
</li>
<li>
<h5>action: <a href="../globals.html#action" class="tsd-signature-type">Action</a></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">S</span></h4>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="subduxupreducer" class="tsd-anchor"></a>
<h3>subdux<wbr>Upreducer</h3>
<ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> subduxUpreducer<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">function</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L212">updux.ts:212</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Returns the upreducer made of the merge of all sudbuxes reducers, without
the local mutations. Useful, for example, for sink mutations.</p>
</div>
<dl class="tsd-comment-tags">
<dt>example</dt>
<dd><pre><code><span class="hljs-keyword">import</span> todo <span class="hljs-keyword">from</span> <span class="hljs-string">'./todo'</span>; <span class="hljs-comment">// updux for a single todo</span>
<span class="hljs-keyword">import</span> Updux <span class="hljs-keyword">from</span> <span class="hljs-string">'updux'</span>;
<span class="hljs-keyword">import</span> u <span class="hljs-keyword">from</span> <span class="hljs-string">'updeep'</span>;
<span class="hljs-keyword">const</span> todos = <span class="hljs-keyword">new</span> Updux({ initial: [], subduxes: { <span class="hljs-string">'*'</span>: todo } });
todos.addMutation(
todo.actions.done,
<span class="hljs-function">(<span class="hljs-params">{todo_id},action</span>) =&gt;</span> u.map( u.if( u.is(<span class="hljs-string">'id'</span>,todo_id) ), todos.subduxUpreducer(action) )
<span class="hljs-literal">true</span>
);</code></pre></dd>
</dl>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">function</span></h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>action<span class="tsd-signature-symbol">: </span><a href="../globals.html#action" class="tsd-signature-type">Action</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">function</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>action: <a href="../globals.html#action" class="tsd-signature-type">Action</a></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">function</span></h4>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>state<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">S</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>state: <span class="tsd-signature-type">S</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">S</span></h4>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="upreducer" class="tsd-anchor"></a>
<h3>upreducer</h3>
<ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> upreducer<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../globals.html#upreducer" class="tsd-signature-type">Upreducer</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L174">updux.ts:174</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <a href="../globals.html#upreducer" class="tsd-signature-type">Upreducer</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Methods</h2>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter">
<a name="addmutation" class="tsd-anchor"></a>
<h3>add<wbr>Mutation</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter">
<li class="tsd-signature tsd-kind-icon">add<wbr>Mutation&lt;A&gt;<span class="tsd-signature-symbol">(</span>creator<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">A</span>, mutation<span class="tsd-signature-symbol">: </span><a href="../globals.html#mutation" class="tsd-signature-type">Mutation</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">A extends (...args: any[]) &#x3D;&gt; infer R ? R : never</span><span class="tsd-signature-symbol">&gt;</span>, isSink<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">false</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/yanick/updux/blob/8d4542f/src/updux.ts#L283">updux.ts:283</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Adds a mutation and its associated action to the updux.
If a local mutation was already associated to the action,
it will be replaced by the new one.</p>
</div>
<dl class="tsd-comment-tags">
<dt>example</dt>
<dd><pre><code>updux.addMutation( add, inc =&gt; <span class="hljs-keyword">state</span> =&gt; <span class="hljs-keyword">state</span> + inc );</code></pre></dd>
</dl>
</div>
<h4 class="tsd-type-parameters-title">Type parameters</h4>
<ul class="tsd-type-parameters">
<li>
<h4>A<span class="tsd-signature-symbol">: </span><a href="../globals.html#actioncreator" class="tsd-signature-type">ActionCreator</a></h4>
</li>
</ul>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>creator: <span class="tsd-signature-type">A</span></h5>
</li>
<li>
<h5>mutation: <a href="../globals.html#mutation" class="tsd-signature-type">Mutation</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">A extends (...args: any[]) &#x3D;&gt; infer R ? R : never</span><span class="tsd-signature-symbol">&gt;</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> isSink: <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">false</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">true</span></h5>
<div class="tsd-comment tsd-typography">
<p>If <code>true</code>, disables the subduxes mutations for this action. To
conditionally run the subduxes mutations, check out <a href="updux.html#subduxupreducer">subduxUpreducer</a>.</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="globals ">
<a href="../globals.html"><em>Globals</em></a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
</ul>
<ul class="current">
<li class="current tsd-kind-class tsd-has-type-parameter">
<a href="updux.html" class="tsd-kind-icon">Updux</a>
<ul>
<li class=" tsd-kind-constructor tsd-parent-kind-class">
<a href="updux.html#constructor" class="tsd-kind-icon">constructor</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class">
<a href="updux.html#groommutations" class="tsd-kind-icon">groom<wbr>Mutations</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class">
<a href="updux.html#initial" class="tsd-kind-icon">initial</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class">
<a href="updux.html#subduxes" class="tsd-kind-icon">subduxes</a>
</li>
<li class=" tsd-kind-get-signature tsd-parent-kind-class">
<a href="updux.html#actions" class="tsd-kind-icon">actions</a>
</li>
<li class=" tsd-kind-get-signature tsd-parent-kind-class">
<a href="updux.html#asdux" class="tsd-kind-icon">as<wbr>Dux</a>
</li>
<li class=" tsd-kind-get-signature tsd-parent-kind-class">
<a href="updux.html#createstore" class="tsd-kind-icon">create<wbr>Store</a>
</li>
<li class=" tsd-kind-get-signature tsd-parent-kind-class">
<a href="updux.html#middleware" class="tsd-kind-icon">middleware</a>
</li>
<li class=" tsd-kind-get-signature tsd-parent-kind-class">
<a href="updux.html#mutations" class="tsd-kind-icon">mutations</a>
</li>
<li class=" tsd-kind-get-signature tsd-parent-kind-class">
<a href="updux.html#reducer" class="tsd-kind-icon">reducer</a>
</li>
<li class=" tsd-kind-get-signature tsd-parent-kind-class">
<a href="updux.html#subduxupreducer" class="tsd-kind-icon">subdux<wbr>Upreducer</a>
</li>
<li class=" tsd-kind-get-signature tsd-parent-kind-class">
<a href="updux.html#upreducer" class="tsd-kind-icon">upreducer</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter">
<a href="updux.html#addmutation" class="tsd-kind-icon">add<wbr>Mutation</a>
</li>
</ul>
</li>
</ul>
<ul class="after-current">
<li class=" tsd-kind-interface tsd-has-type-parameter">
<a href="../interfaces/upduxmiddlewareapi.html" class="tsd-kind-icon">Updux<wbr>MiddlewareAPI</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter">
<a href="../globals.html#action" class="tsd-kind-icon">Action</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter">
<a href="../globals.html#actioncreator" class="tsd-kind-icon">Action<wbr>Creator</a>
</li>
<li class=" tsd-kind-type-alias tsd-is-not-exported">
<a href="../globals.html#actionpair" class="tsd-kind-icon">Action<wbr>Pair</a>
</li>
<li class=" tsd-kind-type-alias">
<a href="../globals.html#actionpayloadgenerator" class="tsd-kind-icon">Action<wbr>Payload<wbr>Generator</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter">
<a href="../globals.html#dictionary" class="tsd-kind-icon">Dictionary</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter">
<a href="../globals.html#dux" class="tsd-kind-icon">Dux</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter tsd-is-not-exported">
<a href="../globals.html#maybepayload" class="tsd-kind-icon">Maybe<wbr>Payload</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter">
<a href="../globals.html#mutation" class="tsd-kind-icon">Mutation</a>
</li>
<li class=" tsd-kind-type-alias tsd-is-not-exported">
<a href="../globals.html#next" class="tsd-kind-icon">Next</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter tsd-is-not-exported">
<a href="../globals.html#storewithdispatchactions" class="tsd-kind-icon">Store<wbr>With<wbr>Dispatch<wbr>Actions</a>
</li>
<li class=" tsd-kind-type-alias tsd-is-not-exported">
<a href="../globals.html#submutations" class="tsd-kind-icon">Sub<wbr>Mutations</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter">
<a href="../globals.html#upduxconfig" class="tsd-kind-icon">Updux<wbr>Config</a>
</li>
<li class=" tsd-kind-type-alias">
<a href="../globals.html#upduxdispatch" class="tsd-kind-icon">Updux<wbr>Dispatch</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter">
<a href="../globals.html#upduxmiddleware" class="tsd-kind-icon">Updux<wbr>Middleware</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter">
<a href="../globals.html#upreducer" class="tsd-kind-icon">Upreducer</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="../globals.html#middlewarefor" class="tsd-kind-icon">Middleware<wbr>For</a>
</li>
<li class=" tsd-kind-function tsd-has-type-parameter">
<a href="../globals.html#actioncreator" class="tsd-kind-icon">action<wbr>Creator</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="../globals.html#actionfor" class="tsd-kind-icon">action<wbr>For</a>
</li>
<li class=" tsd-kind-function">
<a href="../globals.html#buildactions" class="tsd-kind-icon">build<wbr>Actions</a>
</li>
<li class=" tsd-kind-function tsd-has-type-parameter">
<a href="../globals.html#buildcreatestore" class="tsd-kind-icon">build<wbr>Create<wbr>Store</a>
</li>
<li class=" tsd-kind-function tsd-has-type-parameter">
<a href="../globals.html#buildinitial" class="tsd-kind-icon">build<wbr>Initial</a>
</li>
<li class=" tsd-kind-function tsd-has-type-parameter">
<a href="../globals.html#buildmiddleware" class="tsd-kind-icon">build<wbr>Middleware</a>
</li>
<li class=" tsd-kind-function">
<a href="../globals.html#buildmutations" class="tsd-kind-icon">build<wbr>Mutations</a>
</li>
<li class=" tsd-kind-function tsd-has-type-parameter">
<a href="../globals.html#buildupreducer" class="tsd-kind-icon">build<wbr>Upreducer</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="../globals.html#composemutations" class="tsd-kind-icon">compose<wbr>Mutations</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="../globals.html#slicemw" class="tsd-kind-icon">slice<wbr>Mw</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li>
<li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li>
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
<li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
<li class="tsd-kind-type-alias tsd-has-type-parameter"><span class="tsd-kind-icon">Type alias with type parameter</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
<li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li>
<li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
<li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
<li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="../assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="../assets/js/search.js"><' + '/script>');</script>
</body>
</html>