3
함께 축삭을 약속하고 업로드 진행 상황을 사용하여 깨끗한/짧은/오른쪽 방법 있나요? 이 기능은 약속을 반환Redux Saga, Axios 및 progress 이벤트
function upload(payload, onProgress) {
const url = '/sources/upload';
const data = new FormData();
data.append('source', payload.file, payload.file.name);
const config = {
onUploadProgress: onProgress,
withCredentials: true
};
return axios.post(url, data, config);
}
:
내가 다음 업로드 기능을 가지고 가정하자.
function* uploadSaga(action) {
try {
const response = yield call(upload, payload, [?? anyProgressFunction ??]);
yield put({ type: UPLOADING_SUCCESS, payload: response });
} catch (err) {
yield put({ type: UPLOADING_FAIL, payload: err });
}
}
내가 진행 이벤트를 수신하고 사가로 넣어 원하는 :
또한 나는 사가있다. 또한 나는 축삭 요청의 성공 (또는 실패) 결과를 잡아 내고 싶다. 가능한가?감사합니다.
대신 eventEmitter가 'eventChannel'이되어야합니까? –