我有一个异步发布图像的功能。我使用Promise.all()
就像这样:
function post_media() {
return dispatch => {
allPromises[key] = dispatch(upload_my_photo().then(response => {
return response.json()
}).then(response => {
if(getState().process.reset){
// I want to reject the Promise and call the same function again
// return dispatch(post_media() and stop uploading photos and restart the function again)
}
}))
return Promise.all(allPromises)
)}
}
如果我getState().process.reset
我想停止上传其他照片并再次调用该功能?
我该如何实现?