Skip to content

Commit a01bf0c

Browse files
committed
Update README
1 parent d56096b commit a01bf0c

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
<div align="center">
22
<img src="img/icon.png" width="30%">
33
<h1>react-native-multithreading</h2>
4+
<h3>🧵 Fast and easy multithreading for React Native using JSI.</h3>
5+
<br/>
6+
<a align="center" href='https://ko-fi.com/F1F8CLXG' target='_blank'>
7+
<img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi2.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' />
8+
</a>
9+
<br/>
10+
<a align="center" href="https://github.com/mrousavy?tab=followers">
11+
<img src="https://img.shields.io/github/followers/mrousavy?label=Follow%20%40mrousavy&style=social" />
12+
</a>
13+
<br/>
14+
<a align="center" href="https://twitter.com/mrousavy">
15+
<img src="https://img.shields.io/twitter/follow/mrousavy?label=Follow%20%40mrousavy&style=social" />
16+
</a>
417
</div>
5-
6-
Fast and easy multithreading for React Native using JSI.
18+
<br/>
719

820
## Installation
921

@@ -27,6 +39,7 @@ To simply do expensive calculation on another thread without caring about result
2739
```ts
2840
// JS thread
2941
spawnThread(() => {
42+
'worklet'
3043
// custom thread
3144
// expensive calculation
3245
})
@@ -41,8 +54,9 @@ Since `spawnThread` returns a `Promise`, you can also await the result. The Reac
4154

4255
```ts
4356
const result = await spawnThread(() => {
57+
'worklet'
4458
// expensive calculation
45-
return ...;
59+
return ...
4660
})
4761
```
4862

@@ -52,12 +66,14 @@ This example calculates the [Fibonacci Number](https://en.wikipedia.org/wiki/Fib
5266

5367
```ts
5468
const fibonacci = (num: number): number => {
69+
'worklet'
5570
if (num <= 1) return 1
5671
return fibonacci(num - 1) + fibonacci(num - 2)
5772
}
5873

5974
const input = 50
6075
const result = await spawnThread(() => {
76+
'worklet'
6177
console.log(`calculating fibonacci for input: ${input}...`)
6278
const fib = fibonacci(input)
6379
console.log("finished calculating fibonacci!")
@@ -66,6 +82,12 @@ const result = await spawnThread(() => {
6682
console.log(`Fibonacci Result: ${result}`)
6783
```
6884

85+
## Limitations
86+
87+
1. At the moment, only iOS is implemented.
88+
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).
89+
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.
90+
6991
## License
7092

7193
MIT
@@ -74,5 +96,6 @@ MIT
7496

7597
* [react-native-reanimated](http://github.com/software-mansion/react-native-reanimated) for Shared Value adapting, essentially allowing JSI multithreading
7698
* [Erik the Coder](https://www.erikthecoder.net/2019/03/30/async-does-not-imply-concurrent/) for the Icon
99+
* You, for appreciating my work
77100

78101
> Note: Technically this is not [multithreading](https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)), but rather [multiprocessing](https://en.wikipedia.org/wiki/Multiprocessing).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-multithreading",
33
"version": "0.1.0",
4-
"description": "Fast and easy multithreading for React Native using JSI",
4+
"description": "🧵 Fast and easy multithreading for React Native using JSI",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
77
"types": "lib/typescript/src/index.d.ts",

0 commit comments

Comments
 (0)