build-your-own-angularjs
build-your-own-angularjs copied to clipboard
Wrong reasoning for why `$q.when()` required no extra work to adopt foreign promises
Notice that we didn’t really have to do anything to make the adoption of foreign Promises work. That’s because our then implementation already knows how to wrap a foreign Promise, and when merely wraps then.
then
implementation is not aware of wrapping foreign promise, resolve
is.
defer.resolve(value)
knows if the value being passed is a thenable (foreing promise) and waits until the foregin promise is resolved before resolving itself.