Skip to content

Commit

Permalink
docs: improve examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarnespaychex committed Oct 22, 2019
1 parent 3f20cb4 commit 976ed37
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 182 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ BloodhoundPromise.all([

What does the code do? Both `loadMessages` and `loadAppData` return a promise that will resolve once their data calls complete. Because the promises are being returned, we do not call `done()` -- after all, we need these promises for our call to `BloodhoundPromise.all`, so we can't end the chain just yet.

then, we wrap our promises in a call to `BloodhoundPromise.all`, a static method that returns a promise which is only resolved if all child promises resolve.
Then, we wrap our promises in a call to `BloodhoundPromise.all`, a static method that returns a promise which is only resolved if all child promises resolve.

Finally, we call `done()`, which waits until the promise is either resolved or rejected to check for unhandled exceptions. If one of our data calls failed, an error will be thrown at this point. Otherwise, the error might be swallowed.

Expand All @@ -136,8 +136,8 @@ BloodhoundPromise.config.setErrorHandler(function handler(reason) {
Sometimes you want to know that an asynchronous operation has occurred so you can perform change detection. Frameworks like AngularJS need this information to ensure that bindings are updated correctly.

```javascript
angular.module('myapp', [])
.run(['$rootScope', function($rootScope) {
angular.module('myapp', ['ng'])
.run(['$rootScope', function checkForChanges($rootScope) {
function checkChanges() {
$rootScope.$applyAsync();
}
Expand Down
206 changes: 140 additions & 66 deletions docs/BloodhoundPromise.html

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h4 class="name" id="AsyncNotifier"><span class="type-signature"></span>AsyncNot

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line57">line 57</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line58">line 58</a>
</li></ul></dd>


Expand Down Expand Up @@ -223,7 +223,7 @@ <h4 class="name" id="Config">Config</h4>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line74">line 74</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line75">line 75</a>
</li></ul></dd>


Expand Down Expand Up @@ -304,7 +304,7 @@ <h5 class="subsection-title">Properties:</h5>

<td class="description last"><p>Registers a callback to invoke when the
wrapped Promise's scheduler is used (e.g. when invoking success and failure handlers
passed to <code>.then(...)</code>).</p></td>
passed to <code>.then()</code>).</p></td>
</tr>


Expand Down Expand Up @@ -375,7 +375,7 @@ <h4 class="name" id="Defer">Defer</h4>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line27">line 27</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line28">line 28</a>
</li></ul></dd>


Expand Down Expand Up @@ -574,7 +574,7 @@ <h4 class="name" id="ErrorHandler"><span class="type-signature"></span>ErrorHand

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line39">line 39</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line40">line 40</a>
</li></ul></dd>


Expand Down Expand Up @@ -710,7 +710,7 @@ <h4 class="name" id="Executor"><span class="type-signature"></span>Executor<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line17">line 17</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line18">line 18</a>
</li></ul></dd>


Expand Down Expand Up @@ -870,7 +870,7 @@ <h4 class="name" id="SetAsyncNotifier"><span class="type-signature"></span>SetAs

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line64">line 64</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line65">line 65</a>
</li></ul></dd>


Expand Down Expand Up @@ -912,7 +912,7 @@ <h4 class="name" id="SetAsyncNotifier"><span class="type-signature"></span>SetAs
<div class="description">
<p>Registers a callback to invoke when the
wrapped Promise's scheduler is used (e.g. when invoking success and failure handlers
passed to <code>.then(...)</code>).</p>
passed to <code>.then()</code>).</p>
</div>


Expand Down Expand Up @@ -1008,7 +1008,7 @@ <h4 class="name" id="SetErrorHandler"><span class="type-signature"></span>SetErr

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line47">line 47</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line48">line 48</a>
</li></ul></dd>


Expand Down Expand Up @@ -1147,7 +1147,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Wed Sep 04 2019 14:45:45 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Oct 22 2019 10:46:02 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
8 changes: 4 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h3>Explicit Promise Chains</h3>
]).done();
</code></pre>
<p>What does the code do? Both <code>loadMessages</code> and <code>loadAppData</code> return a promise that will resolve once their data calls complete. Because the promises are being returned, we do not call <code>done()</code> -- after all, we need these promises for our call to <code>BloodhoundPromise.all</code>, so we can't end the chain just yet.</p>
<p>then, we wrap our promises in a call to <code>BloodhoundPromise.all</code>, a static method that returns a promise which is only resolved if all child promises resolve.</p>
<p>Then, we wrap our promises in a call to <code>BloodhoundPromise.all</code>, a static method that returns a promise which is only resolved if all child promises resolve.</p>
<p>Finally, we call <code>done()</code>, which waits until the promise is either resolved or rejected to check for unhandled exceptions. If one of our data calls failed, an error will be thrown at this point. Otherwise, the error might be swallowed.</p>
<h3>Easy Configuration</h3>
<p>Bloodhound is configurable.</p>
Expand All @@ -146,8 +146,8 @@ <h4>custom handler for any unhandled rejections</h4>
</code></pre>
<h4>callback for asynchronous operations</h4>
<p>Sometimes you want to know that an asynchronous operation has occurred so you can perform change detection. Frameworks like AngularJS need this information to ensure that bindings are updated correctly.</p>
<pre class="prettyprint source lang-javascript"><code>angular.module('myapp', [])
.run(['$rootScope', function($rootScope) {
<pre class="prettyprint source lang-javascript"><code>angular.module('myapp', ['ng'])
.run(['$rootScope', function checkForChanges($rootScope) {
function checkChanges() {
$rootScope.$applyAsync();
}
Expand Down Expand Up @@ -185,7 +185,7 @@ <h2>Copyright</h2>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Wed Sep 04 2019 14:45:45 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Oct 22 2019 10:46:02 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
Loading

0 comments on commit 976ed37

Please sign in to comment.