Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can use implicit args in auto and autoinject #1387

Closed
mjafarpour opened this issue Mar 18, 2017 · 3 comments
Closed

How can use implicit args in auto and autoinject #1387

mjafarpour opened this issue Mar 18, 2017 · 3 comments
Labels

Comments

@mjafarpour
Copy link

Hi,
How can i use implicit args list for auto and autoinject.
I use async 2.1.5 and nodeJs 4.2.6

eg:

var args = [ 'arg1', 'arg2', 'arg3' ] ,
funcList = {
arg1: function(cb){ cb(null,'xyz') },
arg2: function(cb){ cb(null,'xyz') },
arg3: function(cb){ cb(null,'xyz') }
}

funcList[ 'arg4' ] = [args, function( r, cb ){
// use or change r[ args[0] ] or r[ args[1] ] ...
}]

async.auto(funcList, callback);

at the run time i get Error: async.auto task arg4 has a non-existent dependency arg1, arg2, arg3 in arg1, arg2, arg3

@aearly
Copy link
Collaborator

aearly commented Mar 18, 2017

Change it to:

funcList[ 'arg4' ] = args.concat(function( r, cb ){
  // use or change r[ args[0] ] or r[ args[1] ] ...
})

@mjafarpour
Copy link
Author

mjafarpour commented Mar 18, 2017

Thanks, it's worked with auto method but how can use it for autoinject?

@aearly
Copy link
Collaborator

aearly commented Mar 18, 2017

You can't have dynamic args in autoInject. All args have to be explicit in the function definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants