multi threading in react-native
You can use WebView which will run JS in background thread. Because inside webview, it is another instance of Webkit, so JS running in it won’t block the app UI at all.
Read this blogpost for more detail: https://medium.com/@inkdrop/a-simple-way-to-run-js-in-background-thread-on-react-native-8fff345576da
cancan
Updated on June 09, 2022Comments
-
cancan almost 2 years
I have a React-Native application and I want to use parallel programming (I want to use all of the cores of the tablet).
I tried
paralleljs
andhamsters.js
libraries but they were not useful. One doesn't support RN and the other has some issues with Blobs at the moment.So, I decided to use web-workers. After doing some search on it (from MDN etc), I realized that I might use web workers alone instead of all these libraries. However I can't be 100% sure about it. There are other libraries designed for RN, like react-native-workers, but all has lots of issues.
My question is how to use pure JS code to make use multi-threading and/or parallel programming in a React-Native application? Or is it not possible yet?
-
SEoF almost 5 yearsNeither
setTimeout
nornew Promise
run code on new threads. They both just operate on the main thread, but with different priorities and make use of event interruptions.