Skip to content

Commit e09cbe8

Browse files
committed
readme fix
1 parent 05245bb commit e09cbe8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/worker-task-queue/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This is a standalone implementation of the cooperative multithreading model from [Task Worklet](https://github.com/developit/task-worklet) as a zero-dependency library for Web and Node.
44

5+
**main thread code:**
6+
57
```js
68
import WorkerTaskQueue from 'worker-task-queue';
79

@@ -34,3 +36,30 @@ function demo(image) {
3436

3537
demo();
3638
```
39+
40+
**worker code:**
41+
42+
```js
43+
import { registerTask } from 'worker-task-queue/processor';
44+
45+
registerTask('crop', class {
46+
process(image, { box }) {
47+
// complicated stuff in here
48+
return image;
49+
}
50+
});
51+
52+
registerTask('resize', class {
53+
process(image, { width, height }) {
54+
// complicated stuff in here
55+
return image;
56+
}
57+
});
58+
59+
registerTask('compress', class {
60+
process(image, quality) {
61+
// complicated stuff in here
62+
return image;
63+
}
64+
});
65+
```

0 commit comments

Comments
 (0)