The accepted answer for How do I convert an existing callback API to promises? has this example:
function getUserDataAsync(userId){
return new Promise(function(resolve,reject){
getUserData(userId,resolve,reject);
});
}
Questions:
Shouldn't the body of
Promise
return something, not just callgetUserData
(at least in practical code, not as promise demonstration exercise)?Is this particular
Promise
also a closure? It seems like it closes overuserId
, asgetUserDataAsync
creates and returns a newPromise
instance usinguserId
, but I want to be sure.