We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@sorrycc
比如,参考 JakeChampion/fetch#89 (comment) 这里写了个带进度回调的上传异步函数 futch,然后在 effects 里
futch
yield call(futch, '/', {}, (event) => { put({ type: 'progress', payload: event }) })
这样是不行的,或者写成
yield call(futch, '/', {}, function *(event) { yield put({ type: 'progress', payload: event }) })
那在 futch 里怎么触发这个 Generator 函数并传入参数?
The text was updated successfully, but these errors were encountered:
解决了,用第二种写法,传入 Generator 函数,在 futch 里
xhr.upload.onprogress = (event) => { onProgress(event).next() }
Sorry, something went wrong.
但是仍然有问题,yield put({ type: 'progress', payload: event }) 这个 Action 无法被对应的 reducer 接收到
yield put({ type: 'progress', payload: event })
已完美解决
参考了 #322 提到的 https://stackoverflow.com/questions/40685288/redux-saga-upload-file-progress-event
使用了 axios,在 Component 里直接发起请求并解析请求的 Promise,在 onUploadProgress 回调里 dispatch 上传进度的消息,使用 CancelToken 来取消上传
axios
onUploadProgress
CancelToken
这个需求在 effects 里确实不好做
@mdluo 在Component里直接发起请求感觉是跳过了saga的effects……我感觉解决方法不完美啊。
No branches or pull requests
@sorrycc
比如,参考 JakeChampion/fetch#89 (comment) 这里写了个带进度回调的上传异步函数
futch
,然后在 effects 里这样是不行的,或者写成
那在
futch
里怎么触发这个 Generator 函数并传入参数?The text was updated successfully, but these errors were encountered: