android - What to run some functions in the background in React Native (To Avoid blocking the main thread) - Stack Overflow

In my react-native app, I need to process 12sets of data 20 times every second. It has resulted the app

In my react-native app, I need to process 12sets of data 20 times every second. It has resulted the application to work slow on older mobile phones. I can't understand how to run this function separately on the background.

  1. I have already tried few libraries like react-native-threads or react-native-worklets-core. The first is pretty old and the second one doesnt work (or atleast their documents is old).
  2. I researched a bit and it seems like I can also use Native Models or use WASM.

I was wondering is there a better and more efficient way to do this that I don't know about?

In my react-native app, I need to process 12sets of data 20 times every second. It has resulted the application to work slow on older mobile phones. I can't understand how to run this function separately on the background.

  1. I have already tried few libraries like react-native-threads or react-native-worklets-core. The first is pretty old and the second one doesnt work (or atleast their documents is old).
  2. I researched a bit and it seems like I can also use Native Models or use WASM.

I was wondering is there a better and more efficient way to do this that I don't know about?

Share Improve this question asked Mar 10 at 15:36 nawzneennawzneen 1411 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Perhaps you could consider wrapping your function inside setTimeout as it uses the browser's Web API to handle the delay externally, allowing JavaScript to continue running

setTimeout(()=>{
  // function
})

https://medium/@ashishkumarjena1437/understanding-how-settimeout-works-in-javascripts-single-threaded-environment-dd5889ea1599#:~:text=JavaScript%20is%20single%2Dthreaded%2C%20meaning,moves%20to%20the%20callback%20queue.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744837635a4596360.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信