summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorkybernetikos <me@kybernetikos.com>2014-02-12 14:06:17 +0000
committerkybernetikos <me@kybernetikos.com>2014-02-12 14:06:17 +0000
commiteea14ed194dff46540eee196400acdfc0c8b7480 (patch)
treec9c1607443f842af2d140fd7cbda6684309140da /README.md
parent2d5bc3f5a6db2d699646e59a551355a21cd98637 (diff)
downloadasync-eea14ed194dff46540eee196400acdfc0c8b7480.tar.gz
Added a little more description to 'forever'
The forever section is unclear at present because there are two callback functions in play (the second argument in forever, and the first argument for fn), and also because it's not made clear that execution will stop if next is not called or if next is called with an argument. This change is my suggestion to make it a little clearer.
Diffstat (limited to 'README.md')
-rw-r--r--README.md23
1 files changed, 19 insertions, 4 deletions
diff --git a/README.md b/README.md
index 951f76e..02a4877 100644
--- a/README.md
+++ b/README.md
@@ -800,11 +800,26 @@ Like doWhilst except the test is inverted. Note the argument ordering differs fr
---------------------------------------
<a name="forever" />
-### forever(fn, callback)
+### forever(fn, errback)
-Calls the asynchronous function 'fn' repeatedly, in series, indefinitely.
-If an error is passed to fn's callback then 'callback' is called with the
-error, otherwise it will never be called.
+Calls the asynchronous function 'fn' with a callback parameter that allows it to
+call itself again, in series, indefinitely.
+
+If an error is passed to the callback then 'errback' is called with the
+error, and execution stops, otherwise it will never be called.
+
+```js
+async.forever(
+ function(next) {
+ // next is suitable for passing to things that need a callback(err [, whatever]);
+ // it will result in this function being called again.
+ },
+ function(err) {
+ // if next is called with a value in its first parameter, it will appear
+ // in here as 'err', and execution will stop.
+ }
+);
+```
---------------------------------------