Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkin committed Oct 30, 2017
1 parent 3884e81 commit 69c8fa2
Show file tree
Hide file tree
Showing 11 changed files with 416 additions and 40 deletions.
68 changes: 46 additions & 22 deletions dist/sequential-event.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sequential-event.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/sequential-event.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/SequentialEvent.html
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2017-10-30T19:51:10+01:00
on 2017-10-30T23:02:18+01:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2017-10-30T19:51:10+01:00
on 2017-10-30T23:02:18+01:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
26 changes: 17 additions & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
<blockquote>
<p><strong>See the API documentation on <a href="https://gerkindev.github.io/SequentialEvent.js/">github.io/SequentialEvent.js</a></strong></p>
</blockquote>
<p>This library is a variation of standard event emitters. Handlers are executed sequentialy, and may return <strong>Promises</strong> if it executes asynchronous code.</p>
<p>This library is a variation of standard event emitters. Handlers are executed
sequentialy, and may return <strong>Promises</strong> if it executes asynchronous code.</p>
<p>For usage in the browser, use the files in the <code>dist</code> directory</p>
<h2>Example usage</h2><pre class="prettyprint source lang-javascript"><code>const SequentialEvent = require( 'sequential-event' );

Expand All @@ -113,7 +114,8 @@ <h2>Example usage</h2><pre class="prettyprint source lang-javascript"><code>cons
});
// We wait 100ms and we re-time
eventEmitter.on( 'retime', ( startTime, timers ) => {
// This operation is async, so we return a Promise that will be resolved with the timers array
// This operation is async, so we return a Promise that will be resolved
// with the timers array
return new Promise(( resolve ) => {
setTimeout(() => {
timers.push( sampleTime( startTime ));
Expand All @@ -133,12 +135,15 @@ <h2>Example usage</h2><pre class="prettyprint source lang-javascript"><code>cons
.emit( 'retime', new Date().getTime())
// Log normaly if everything is OK, or log with error
.then( timers => console.log( timers ))
.catch( err => console.error( err ));</code></pre><p><em>Sample output</em></p>
.catch( err => console.error( err ));</code></pre><p>Here is an example of output of this code:</p>
<blockquote>
<p>[ 1, 109, 109 ]</p>
</blockquote>
<p>You can see that each <code>on</code> handlers are executed sequentially, after the end of the previous handler.</p>
<h2>API</h2><h3>emit</h3><p>Triggers all listeners of the provided events, spraying <code>params</code> to each callbacks. Returned or resolved values from callbacks (if returning a <code>Promise</code>) are passed as last parameter of the next callback function.</p>
<p>You can see that each <code>on</code> handlers are executed sequentially, after the end of
the previous handler.</p>
<h2>API</h2><h3>emit</h3><p>Triggers all listeners of the provided events, spraying <code>params</code> to each
callbacks. Returned or resolved values from callbacks (if returning a
<code>Promise</code>) are passed as last parameter of the next callback function.</p>
<p>Signature:</p>
<blockquote>
<p>emit(<em>string</em> <code>eventName</code>[, <em>...any</em> <code>params</code>]) =&gt; <em>Promise(any)</em></p>
Expand All @@ -158,15 +163,18 @@ <h3>off</h3><p>Remove callbacks from events.</p>
eventListener.off({
event1: cbFoo,
event2: cbBar,
});</code></pre><h3>once</h3><p>Bind callbacks to specified events. The callback will be executable a single time for each event.</p>
});</code></pre><h3>once</h3><p>Bind callbacks to specified events. The callback will be executable a single
time for each event.</p>
<p>Signatures:</p>
<blockquote>
<p>once(<em>string</em> <code>eventName</code>, <em>function</em> <code>callback</code>) =&gt; <em>this</em></p>
<p>once(<em>object</em> <code>events</code> ) =&gt; <em>this</em></p>
</blockquote>
<pre class="prettyprint source"><code>// Attach the same callback to `event1` & `event2`. `event1` callback may be executed a single time, as `event2`.
<pre class="prettyprint source"><code>// Attach the same callback to `event1` & `event2`. `event1` callback may be
// executed a single time, as `event2`.
eventListener.once( 'event1 event2', () => Promise.resolve( 'foo' ));
// Bind a callback that returns 'foo' on `event1`, and 'bar' on `event2`. Both will be run a single time.
// Bind a callback that returns 'foo' on `event1`, and 'bar' on `event2`. Both
// will be run a single time.
eventListener.once({
event1: () => Promise.resolve( 'foo' ),
event2: () => Promise.resolve( 'bar' ),
Expand Down Expand Up @@ -327,7 +335,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2017-10-30T19:51:10+01:00
on 2017-10-30T23:02:18+01:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
Loading

0 comments on commit 69c8fa2

Please sign in to comment.