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.

679 lines (189 loc) 8.48 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: StateUpdaterOnActions</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">Class: StateUpdaterOnActions</h1> <section> <header> <h2><span class="attribs"><span class="type-signature"></span></span>StateUpdaterOnActions<span class="signature">()</span><span class="type-signature"></span></h2> </header> <article> <div class="container-overview"> <h4 class="name" id="StateUpdaterOnActions"><span class="type-signature"></span>new StateUpdaterOnActions<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> The state-updater-on-actions interface. <br><br> <b>NOTE this isn't a real class</b>, it's an interface because of JSDoc limitations. <a href="https://stackoverflow.com/questions/23095975/jsdoc-object-methods-with-method-or-property">Related StackOverflow thread</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#line1">line 1</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="call"><span class="type-signature"></span>call<span class="signature">(action, params)</span><span class="type-signature"> &rarr; {Promise}</span></h4> <div class="description"> Calls an action with 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>action</code></td> <td class="type"> <span class="param-type"><a href="global.html#Action">Action</a></span> </td> <td class="description last">The action to call.</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 action when it will be called.</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#line12">line 12</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The promise that the action returns, or if it returns a promise with the value returned by the <code>updateState</code>, it will call the <code>updateAction</code> function passed to the constructor by parameter and if it returns a rejected promise, then it will be returned such rejected promise. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Promise</span> </dd> </dl> <h4 class="name" id="callCtx"><span class="type-signature"></span>callCtx<span class="signature">(action, ctx, params)</span><span class="type-signature"> &rarr; {Promise}</span></h4> <div class="description"> Calls an action using the specified context (e.g obj.action()) and 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>action</code></td> <td class="type"> <span class="param-type"><a href="global.html#Action">Action</a></span> </td> <td class="description last">The action to call.</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. `this` 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 action when it will be called.</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#line26">line 26</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The promise that the action returns, or if it returns a promise with the value returned by the <code>updateState</code> method, it will call the <code>updateAction</code> function passed to the constructor by parameter and if it returns a rejected promise then it will be returned such rejected promise. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Promise</span> </dd> </dl> <h4 class="name" id="updateState"><span class="type-signature"></span>updateState<span class="signature">()</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Returns the value which the actions must resolve their returned promises when they require an state update. </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#line43">line 43</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The value DOES NOT matter as it's used internally to identify that the update state action must be called. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </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>