In the following code, what would be the reason to return another promise from the success
or err
method? As you can see, someFunction
already returns a promise and we could easily return that to the caller.
I don't understand the reason to make another promise while we are not decorating/manipulating the response or the error. Is there a use case that I'm not aware of?
function() {
var p = $q.defer();
someModule.someFunction(input)
.then(
function(success) {
return p.resolve(success);
},
function(err) {
return p.reject(err)
}
);
return p.promise;
};