diff options
author | Alexander Early <alexander.early@gmail.com> | 2016-07-07 17:30:29 -0700 |
---|---|---|
committer | Alexander Early <alexander.early@gmail.com> | 2016-07-07 17:30:29 -0700 |
commit | f9c3f06b5e9343fadc574bb3b762f6a7c46ca452 (patch) | |
tree | 3d494e61e66228bc9c7700f65dfd1c4661690dfb /lib | |
parent | 36c97b7fff9b4d71a14a3d240148486c8e41197a (diff) | |
download | async-f9c3f06b5e9343fadc574bb3b762f6a7c46ca452.tar.gz |
fix autoInject docs. Closes #1216
Diffstat (limited to 'lib')
-rw-r--r-- | lib/autoInject.js | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/autoInject.js b/lib/autoInject.js index 1af1a32..3bb40e2 100644 --- a/lib/autoInject.js +++ b/lib/autoInject.js @@ -50,12 +50,8 @@ function parseParams(func) { * arguments of those parameters. * @param {Function} [callback] - An optional callback which is called when all * the tasks have been completed. It receives the `err` argument if any `tasks` - * pass an error to their callback. The remaining parameters are task names - * whose results you are interested in. This callback will only be called when - * all tasks have finished or an error has occurred, and so do not specify - * dependencies in the same way as `tasks` do. If an error occurs, no further - * `tasks` will be performed, and `results` will only be valid for those tasks - * which managed to complete. Invoked with (err, [results...]). + * pass an error to their callback, and a `results` object with any completed + * task results, similar to `auto`. * @example * * // The example from `auto` can be rewritten as follows: @@ -79,17 +75,16 @@ function parseParams(func) { * // write_file contains the filename returned by write_file. * callback(null, {'file':write_file, 'email':'user@example.com'}); * } - * }, function(err, email_link) { + * }, function(err, results) { * console.log('err = ', err); - * console.log('email_link = ', email_link); + * console.log('email_link = ', results.email_link); * }); * * // If you are using a JS minifier that mangles parameter names, `autoInject` * // will not work with plain functions, since the parameter names will be * // collapsed to a single letter identifier. To work around this, you can * // explicitly specify the names of the parameters your task function needs - * // in an array, similar to Angular.js dependency injection. The final - * // results callback can be provided as an array in the same way. + * // in an array, similar to Angular.js dependency injection. * * // This still has an advantage over plain `auto`, since the results a task * // depends on are still spread into arguments. @@ -102,10 +97,10 @@ function parseParams(func) { * callback(null, {'file':write_file, 'email':'user@example.com'}); * }] * //... - * }, ['email_link', function(err, email_link) { + * }, function(err, results) { * console.log('err = ', err); - * console.log('email_link = ', email_link); - * }]); + * console.log('email_link = ', results.email_link); + * }); */ export default function autoInject(tasks, callback) { var newTasks = {}; |