Skip to content

fix:修复fetch().progress(callback)方法会一直调用callback()问题 #30

New issue

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

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

WN0904
Copy link

@WN0904 WN0904 commented Sep 14, 2024

Summary

  • closes fetch().progress(callback)方法会一直调用callback() #26
  • 修复fetch().progress(callback)方法会一直调用callback()
  • 引起这个问题是因为在监听httpRequest.on('dataSendProgress')时会多次调用,创建多个定时器,而在清理定时器的时候只清理了最后一个定时器,导致还有定时器在运行,实现方案就是在调用时判断有没有定时器如果有就清楚上一个定时器保证只有一个定时器运行

Test Plan

 const fetchprogress = (setState: ArgState) => {
    let task = ReactNativeBlobUtil.config({
      fileCache: true
    })
      .fetch('GET', "http://172.26.224.1:3006/download") .progress({count:-1,interval:1000},(received, total) => {
        console.log('progress ' + Math.floor(received/total*100) + '%')
    })
     
  }

Checklist

  • 已经在真机设备或模拟器上测试通过
  • 已经与 Android 或 iOS 平台做过效果/功能对比
  • 已经添加了对应 API 的测试用例(如需要)
  • 已经更新了文档(如需要)
  • 更新了 JS/TS 代码 (如有)

@mingmingaini mingmingaini merged commit 59423cf into react-native-oh-library:sig Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fetch().progress(callback)方法会一直调用callback()
2 participants