new author, new article, Sequential programming for Node.js #90

Open
wants to merge 5 commits into
from

Conversation

Projects
None yet
4 participants

with links to github repos

Collaborator

kriskowal commented Aug 27, 2013

Thanks for putting this and wait.for together. This article would be about ten times more valuable if it acknowledged and compared alternatives with promises and @creationix’s own genrun proof-of-concept, and acknowledged the interleaving hazards associated with fibers.

Hola Lucio,

Como estas?

I'm about to use wait.for - as it is the only thing I've seen that seems to come near to enabling a non-blocking wait for an async operation to complete under node.js.

Just wanted to check a couple of points to make sure I've really go it.

  1. This really is non-blocking - i.e. the node server can process other incoming page requests whilst wait.for hangs around waiting for an asynchronous function to compete - then enables the later code to use the results synchronously.
  2. wait.for expects a function (say asyncFn()) as argument - with parameters to that function call listed after. More importantly it assumes the last argument of asyncFn to be a callback - which is not supplied in the wait.for but is 'put in automatically' by the wait.for implementation...

So bascially for example doing:
[ callback of form callback(err, data) ]
asyncDBOperation(selectStatement, callback)

value = wait.for(asyncDBOperation) ...

value will be the 'data ' part of the callback function.

  1. If that is correct, seems to me you deserve a medal!

I'm on markcollinscope@gmail.com - if you'd rather reply there - it'd be better.

Thanks.

@creationix thanks a lot! Mark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment