|
|
|
|
|
by distracteddev90
4131 days ago
|
|
Actually would argue that Promises are less composable since you're forced to use whatever control flow paradigm the Promise library has provided or add another library to handle control flow. By utilizing callbacks, you are free to use Async.js[0] or Step.js[1] to solve the problem you described. These libraries are great since they give you control over parallel vs series execution of the pre-requisite functions as well as solving more complex control-flow problems such as throttling, etc[2] (See link for more examples). [0] https://github.com/caolan/async [1] https://github.com/creationix/step [2] https://github.com/caolan/async#control-flow edit: Yes, you can also use similar control-flow libraries with Promises (that follow the specification) to achieve similar results but then the argument for using promises for the sake of control-flow breaks down. |
|
- sequential execution
- parallel execution and wait for all of them to finish
- automated error handling