有没有一种表达方式:
imagePFFileFromUrl(exampUrl) // (returns a promise)
.then(function(xxx))
// that syntax gives you the results of the
// imagePFFileFromUrl inside the variable xxx.
// I then use it in another function which
// returns another promise...
{
return saveImageFile(xxx, anotherArgument) // (returns a promise)
})
.then(function(savedPFFile)
更像这样..
imagePFFileFromUrl(exampUrl)
.then(saveImageFile(...the results from imagePFFileFromUrl ...))
.then(function(savedPFFile)
什么时候使用 promise?
最佳答案
您的 .then() 需要有 1 或 2 个回调函数。如果有 1,它会接受 promise 的已解决值。如果有两个,则第二个采用 promise 的拒绝值。所以,不,你不能做你想做的事。
这是一个很好的example带有两个参数的模式,请注意 return synchUsers
关于javascript - 在 promise 中更直接地使用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32766623/