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.
- 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).
- 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.
- 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).
- 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 badges1 Answer
Reset to default 0Perhaps 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.