我有这个动作创建者:
export const deleteUserFromStoreThenUpdateFirebase = user => {
return (dispatch, getState) => {
return dispatch(deleteUser(user)).then(() => {
return deleteUserFromFirebase(user);
})
};
};
和这个:
export const deleteUser = user => {
return async dispatch => {
dispatch({ type: DELETE_USER, user: user, reqConfirm: true });
};
};
和一些中间件:
const confirmMiddleware = store => next => action => {
if(action.reqConfirm){
if(confirm('are you sure?')){
next(action)
}
}
else {
next(action)
}
}
我只希望以下行调用return deleteUserFromFirebase(user);
:如果此行返回true:dispatch(deleteUser(user)).then(()
,但是当我在中间件中的确认上单击cancel
时。它仍然称呼它。我该如何更改?