Async: How can use implicit args in auto and autoinject

Created on 18 Mar 2017  ·  3Comments  ·  Source: caolan/async

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

question

All 3 comments

Change it to:

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tlbtlbtlb picture tlbtlbtlb  ·  9Comments

joshuambg picture joshuambg  ·  21Comments

ghost picture ghost  ·  9Comments

Kikobeats picture Kikobeats  ·  28Comments

aearly picture aearly  ·  10Comments