javascript承诺所有拒绝

时间:2016-07-25 11:03:15

标签: javascript reactjs es6-promise

我有一个异步发布图像的功能。我使用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我想停止上传其他照片并再次调用该功能?

我该如何实现?

0 个答案:

没有答案