UNPKG

state-updater-on-actions

Version:

Update a shared state by asynchronous actions which execute over a system which responds when the state isn't up to date and expose a refresh operation which returns the value which represents that updated state for enabling the action to proceed.

620 lines (172 loc) 8.08 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Global</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Global</h1> <section> <header> <h2></h2> </header> <article> <div class="container-overview"> <dl class="details"> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="createStateUpdater"><span class="type-signature"></span>createStateUpdater<span class="signature">(updateAction, params)</span><span class="type-signature"> &rarr; {<a href="StateUpdaterOnActions.html">StateUpdaterOnActions</a>}</span></h4> <div class="description"> Create an instance of state updater that uses an action function, which doesn't require to be executed in any context (e.g. a method of an object, or a function which use `this` pointer) and requires the passed parameters. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>updateAction</code></td> <td class="type"> <span class="param-type"><a href="global.html#Action">Action</a></span> </td> <td class="description last">The function which update the shared state require by the actions which will be executed by the returned instance. The function MUST return a promise.</td> </tr> <tr> <td class="name"><code>params</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The parameters to pass to the <code>updateAction</code> each time that it will be executed.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="state-updater.js.html">state-updater.js</a>, <a href="state-updater.js.html#line77">line 77</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The instance which will call the <code>updateAction</code> with the passed parameters when required. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="StateUpdaterOnActions.html">StateUpdaterOnActions</a></span> </dd> </dl> <h4 class="name" id="createStateUpdaterCtx"><span class="type-signature"></span>createStateUpdaterCtx<span class="signature">(updateAction, ctx, params)</span><span class="type-signature"> &rarr; {<a href="StateUpdaterOnActions.html">StateUpdaterOnActions</a>}</span></h4> <div class="description"> Create an instance of state updater that uses an action function, which requires to be executed in any context (e.g. a method of an object, or a function which use <code>this</code> pointer) and requires the passed parameters. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>updateAction</code></td> <td class="type"> <span class="param-type"><a href="global.html#Action">Action</a></span> </td> <td class="description last">The function which update the shared state require by the actions which will be executed by the returned instance. The function MUST return a promise.</td> </tr> <tr> <td class="name"><code>ctx</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The context to use for calling the action (i.e. <code>this</code> pointer).</td> </tr> <tr> <td class="name"><code>params</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The parameters to pass to the <code>updateAction</code> each time that will be executed.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="state-updater.js.html">state-updater.js</a>, <a href="state-updater.js.html#line101">line 101</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The instance which will call the <code>updateAction</code> with the passed parameters when required. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="StateUpdaterOnActions.html">StateUpdaterOnActions</a></span> </dd> </dl> <h3 class="subsection-title">Type Definitions</h3> <h4 class="name" id="Action"><span class="type-signature">(async) </span>Action<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Action is a function which returns a promise; in order to notify that the state must be updated, it MUST return a resolved promise which the value returned by the <a href="StateUpdaterOnActions.html#updateState"><code>updateState</code> method of the <code>StateUpdaterOnActions</code> instance which is used to call the action</a>. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="state-updater.js.html">state-updater.js</a>, <a href="state-updater.js.html#line53">line 53</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="StateUpdaterOnActions.html">StateUpdaterOnActions</a></li></ul><h3>Global</h3><ul><li><a href="global.html#createStateUpdater">createStateUpdater</a></li><li><a href="global.html#createStateUpdaterCtx">createStateUpdaterCtx</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon May 07 2018 16:34:40 GMT+0000 (UTC) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>