Comment

Comment by pedalpete

I'm assuming you've looked at https://www.promisejs.org/generators/

I somewhat agree, prefer callbacks to promises, generators as I see it give you more control of what happens within a promise and how to deal with multiple promises being returned.

The danger I see with promises is they can be used incorrectly. The project I've taken over at work, the developer used a promise as a timer and littered watching the same promise all over the code using ``` Promise(functionToResolve).then(function()... ```

This means we never know where a function is being called from. I don't think you could do something like this with callbacks, instead you'd have to do ``` function(callback(){ // trigger your other methods here } ```

but maybe I'm wrong, I never would have expected somebody to use promises in the way they are used here.

Like'em or not, they are here to stay, and some people like the more synchronous appearance of them and I believe when dealing with an array of promises, generators will provide more fine-grained control.

Keen to hear others thoughts though.

parent pedalpete 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton