0

I am stuck with a very naive problem. Can we pass parameters to function while passing the functions through a function array in async.parallels. Below is a template code. While calling fn1 and fn2 in parallel, i want to pass parameters to each of them.

fn1 = (param , callback) ->
  #somethg 
  # callback

fn2 = (param , callback) ->
  #somethg 
  # callback

async.parallel [fn1 , fn2 ] , (err, result) ->
   # results aggregated from fn1 and fn2
2
  • Sure. Can you provide an example of what you'd like to accomplish? Commented Apr 22, 2014 at 3:20
  • please see the edits :) Commented Apr 22, 2014 at 3:24

1 Answer 1

1

You can specify additional arguments by wrapping the call to each function in another, passing along the callback provided by async.parallel:

arg = 'foo'

async.parallel [
  callback -> fn1 arg, callback,
  callback -> fn2 arg, callback
], (err, result) ->
  console.log result
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.