News for hackers. Stuff that matters.
Re:Understanding Node.js Event-Driven Architecture by NathanKP on Monday May 08, 2017 @10:28AM (#14291720)
I'm just too hooked on the async.auto() pattern to give up callbacks. The ability to break a large flow down into functions and then use a dependency based structure to automatically execute the flow with the most optimal concurrency is incredible. And the resulting code is very clean, with each functional step in the flow living on the same indent level. Refactoring and adding new steps is very easy as you can just add a new dependency to one of the existing functions or add a new function that depends on one of the other functions.

https://caolan.github.io/async/docs.html#auto

Re:Understanding Node.js Event-Driven Architecture by Matthias247 on Monday May 08, 2017 @10:40AM (#14291853)
That looks interesting - as long as you stay in JS land. Once you move into typescript this kind of system will be impossible to typecheck. Promises and their compositions will typecheck just naturally compared to that.
Re:Understanding Node.js Event-Driven Architecture by NathanKP on Monday May 08, 2017 @11:44AM (#14292574)
Yep, there is the autoInject which injects previous dependent functions return values as parameters instead of as properties of a context object, so that may help some, but it still breaks typechecks.

I wish that promises had a concept similar to this. It's simply too annoying for me to manually refactor a bunch of Promise.all() calls to manually adjust the concurrency of the logic flow compared to using the dependency pattern of async.auto().

And based on what I've seen this is a common problem in both async functions, generators, and promises. Since it is difficult to properly execute a tree of functional steps with the maximal concurrency I see code all the time which just runs async functions or promises in a series instead of taking advantage of the ability to concurrently execute two branches of the tree at the same time.

Re:Understanding Node.js Event-Driven Architecture by elithrar on Sunday May 14, 2017 @04:20PM (#14337373)
Have you looked at http://bluebirdjs.com/docs/api/promise.map.html - which allows you to control the concurrency of Promises easily?