Skip to content

Commit

Permalink
fix autoInject docs. Closes #1216
Browse files Browse the repository at this point in the history
  • Loading branch information
aearly committed Jul 8, 2016
1 parent 36c97b7 commit f9c3f06
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions lib/autoInject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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 = {};
Expand Down

0 comments on commit f9c3f06

Please sign in to comment.