promises-aplus / constructor-spec

Discussion and drafts of a possible spec for creating and resolving promises
10 stars 4 forks source link

Return a deferred #2

Open ForbesLindesay opened 11 years ago

ForbesLindesay commented 11 years ago

The way most current implementations work is by having a function which returns a 'deferred': {resolver, promise}.

The deferred concept is a little bit messy, but makes a fair bit of sense. One option would be to avoid calling it a deferred at all in the spec, and just use ES6 terminology:

let {resolver, promise} = defer();

There's also nothing to implementations providing other abstractions, in addition to this one.

domenic commented 11 years ago

I don't think avoiding naming it is a viable approach.

I agree that we can provide e.g. constructors per #3 alongside deferreds for no-nesting convenience.