What is possible with react-native-multithreading?
masterWhen using spawnThread, you have the following capabilities:
- Run arbitrary JS code: Execute any JavaScript logic in the isolated thread.
- Access external variables: You can use variables from the outer scope (e.g., state), but these values are captured and immutable/frozen in the new thread.
- Call external functions:
- Worklets: Functions marked with the
'worklet'directive can be called directly. - Native JSI functions: Host functions (e.g., from
react-native-mmkv) can be called synchronously. - Normal JS functions: Functions like
setStatecan be called back on the React-JS thread using Reanimated'srunOnJS.
- Worklets: Functions marked with the
- Reanimated Shared Values: You can assign and interact with Reanimated Shared Values.