About
React Native Worklets is a library that runs JavaScript code on more than one thread in a React Native app.
The Worklets library adds more JavaScript runtimes to your app:
- The UI Runtime runs on the UI (main) thread. Code on it can respond to every frame and every touch without waiting for the JS thread.
- Worker Runtimes run on their own background threads. You create them for work that must not block either the JS thread or the UI thread.
Code
Colours connect each executing thread to its current code line. Recently executed lines fade over the next three ticks.
CPU
Put it simply, a thread (a core) executes code and might obtain memory resources (like JavaScript Runtimes) for the duration of the execution.
Memory
JavaScript Runtimes and their Event Loops can be thought as exclusive memory resources. Event Loop is usually assigned to one thread and no other thread can obtain it. A Runtime can be obtained by other threads occasionally.
App output
The UI thread updates the app screen. Press the button to queue an input event and follow its result.
Console 0
You can find installation instructions here. If you want to learn more, please look into our tutorials.