diff options
author | Caolan McMahon <caolan@caolanmcmahon.com> | 2014-03-28 12:39:58 +0000 |
---|---|---|
committer | Caolan McMahon <caolan@caolanmcmahon.com> | 2014-03-28 12:39:58 +0000 |
commit | f8cb033c279dc06504cefca66b17c1117b9dcf26 (patch) | |
tree | 0a815dde165d6563fe0fcba522bed5c8d14186d0 /README.md | |
parent | 1346453cd2b4b8831f7765bac703ac63a3f9f124 (diff) | |
parent | eea14ed194dff46540eee196400acdfc0c8b7480 (diff) | |
download | async-f8cb033c279dc06504cefca66b17c1117b9dcf26.tar.gz |
Merge remote-tracking branch 'kybernetikos/patch-1'
Conflicts:
README.md
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -804,11 +804,26 @@ Like [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument o --------------------------------------- <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 is never 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. + } +); +``` --------------------------------------- |