From f9c3f06b5e9343fadc574bb3b762f6a7c46ca452 Mon Sep 17 00:00:00 2001 From: Alexander Early Date: Thu, 7 Jul 2016 17:30:29 -0700 Subject: fix autoInject docs. Closes #1216 --- lib/autoInject.js | 21 ++++++++------------- 1 file 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 = {}; -- cgit v1.2.1