我正在尝试更新进度。
MySaga.js
...
function* putVideo({payload}){
const response = yield axios.put(
payload.signedUrl, payload.file,
{onUploadProgress: (progessEvent) => {
console.log(progressEvent) // I can get progress rate in every seconds.
yield put({ type: 'PROGRESS', progressEvent }); // It doesn't work.
}}
);
if(response.status === 200){
yield put({ type: 'SUCCESS', response}); // It does work well.
}
}
MyStore.js
...
const initialState = {
response: {},
uploadRates: 0,
isUploading: false,
}
export default handleActions({
['SUCCESS']: (state, action) => {
return produce(state, draft=> {
draft.response = action.payload;
draft.uploadRates = 0;
draft.isUploading = false;
});
},
['PROGRESS']: (state, action) => {
return produce(state, draft => {
draft.uploadRates = action.payload;
draft.isUploading = true;
});
}
},initialState);
我错过了什么?或我应该学习