Last active
August 29, 2015 14:19
-
-
Save chinmay185/f9e629470d2e6e983684 to your computer and use it in GitHub Desktop.
unnecessary use of deferred.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getUserEmail = function(username) { | |
var deferred = q.defer(); | |
userRepository.find(username) // assume this returns a promise | |
.then(function(user){ | |
deferred.resolve(user.email); | |
}); | |
return deferred.promise; | |
}; | |
getUserEmail("emma").then(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment