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
Copy file name to clipboardExpand all lines: readme.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,62 @@
6
6
7
7
If you are using some expensive processes inside your webpage, make sure you don't compromise your performance there. Web workers can make your web page feel smooth and realistic
8
8
9
+
## Install
10
+
11
+
Installing this package is super simple and just like any other package. If you are using npm:
12
+
```
13
+
npm i react-web-workers
14
+
```
15
+
16
+
But if you are yarn lover:
17
+
```
18
+
yarn add react-web-workers
19
+
```
20
+
21
+
## Workers
22
+
23
+
Create as many workers as you want as a function and export them just like this:
24
+
```javascript
25
+
constmessage= () => {
26
+
let text ='Hello I am Your Web Worker'
27
+
28
+
constsentData= () => {
29
+
// eslint-disable-next-line no-restricted-globals
30
+
self.postMessage({ text })
31
+
}
32
+
33
+
// eslint-disable-next-line no-restricted-globals
34
+
self.onmessage= ({ data }) => {
35
+
console.log(data)
36
+
sentData()
37
+
}
38
+
}
39
+
40
+
exportdefaultmessage;
41
+
```
42
+
43
+
## Work with Workers
44
+
45
+
Once your workers are ready, import ```react-web-workers```
0 commit comments