duojs / duo

A next-generation package manager for the front-end
3.42k stars 118 forks source link

Consider using more promises internally #449

Closed dominicbarnes closed 9 years ago

dominicbarnes commented 9 years ago

co@4+ now allows yielding promises, and I think we have the opportunity to allow better interoperability if we switch a lot of our current "raw" generators into regular functions that simply return promises. (then consumers could use either callbacks or generators)

I think at the top-level, duo can continue to use generators since it's byfar the most complex repo. But a lot of internals like duo-package, gh-resolve, etc could very easily be converted.

matthewmueller commented 9 years ago

I guess this is the way that the community is moving haha. I still don't really understand what promises give us other than maybe async/await, but I'm pretty sure that could be built on top of thunks which is a simpler, more functional API.

stephenmathieson commented 9 years ago

-1 from me.. promises feel bloated and awkward

dominicbarnes commented 9 years ago

@stephenmathieson I still lean toward what you are saying. However, I think it is worth pointing out that if we use promises, it's possible to support both plain callbacks and generators, which I think is a big win. (especially considering the weird transition period we find ourselves in between node 0.10 and node 0.12/iojs)

stephenmathieson commented 9 years ago

don't we already support generators and callbacks? https://github.com/duojs/duo/blob/0.10.0/lib/duo.js#L410

dominicbarnes commented 9 years ago

Yeah, we do in duo itself, but I'm specifically talking about other internals like gh-resolve and duo-package.

stephenmathieson commented 9 years ago

i don't think we need to worry about how we consume internal APIs, espcially because it's already working just fine. also, it doesn't look like anyone else uses gh-resolve :p

dominicbarnes commented 9 years ago

Yeah, I can get behind that. Haha, I think I've just been really frustrated with the --harmony-generators flag lately.

stephenmathieson commented 9 years ago

just use iojs :p

dominicbarnes commented 9 years ago

Yeah, I do that on all my personal stuff now, but I'm stuck with mostly 0.11 at work atm. :P