You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* You can run any JavaScript code you want in there.
104
104
* You can use variables from "outside" (e.g. state), but those will be immutable/frozen.
105
105
* You can use functions from "outside".
106
-
- Worklets (functions with the `'worklet'` directive) can be called synchronously
107
-
- Normal JS functions (e.g. setState) can be called with `runOnJS`
106
+
- Worklets (functions with the `'worklet'` directive) can be called directly on the separate thread
107
+
- Normal JS functions (e.g. setState) can be called on the React-JS thread with `runOnJS`
108
108
- Native JSI functions ("host functions") can be called synchronously (e.g. functions from [react-native-mmkv](https://github.com/mrousavy/react-native-mmkv#usage))
2. Since the library uses JSI for synchronous native methods access, remote debugging (e.g. with Chrome) is no longer possible. Instead, you should use [Flipper](https://fbflipper.com).
115
115
3. All functions you are calling inside a custom thread, must be workletized to truly run on a separate thread. So add the `'worklet'` directive at the top of every function you're calling in that thread (including the thread callback itself), and don't forget to install the Reanimated babel plugin.
116
116
117
-
## License
117
+
## Supported JS engines
118
118
119
-
MIT
119
+
* JavaScript Core (JSC)
120
+
*[Hermes](http://hermesengine.dev)
121
+
*[V8](http://github.com/Kudo/react-native-v8)
122
+
123
+
## Performance
124
+
125
+
Since the worklets are completely dispatched in an isolated thread, nothing interrupts their execution. This means, the JS engine can optimize the functions really well, making execution fast.
126
+
127
+
Be aware that there always will be a small overhead when calling `spawnThread`, because all variables from outside have to be copied into the new thread first. For example, if you use the separate thread to do complex array operations, be aware that the array has to be copied into the separate thread first. Always benchmark the performance differences!
0 commit comments