GoogleChromeLabs / GoogleChromeLabs/comlink
not working in react
Open
- Dominant language
- TypeScript
- Stars
- 12.8k
- Forks
- 435
- PR merge metrics
- No merged PRs in 30d
Description
I tested all examples in a react application but it don't works
how can I use it in react?
worker.js
```javascript
import * as Comlink from 'comlink';
async function callbackFunction(cb) {
await cb("A string from a worker");
}
Comlink.expose(callbackFunction);
```
index.ts
```javascript
import * as Comlink from 'comlink';
function callback(value) {
alert(`Result: ${value}`);
}
async function init() {
const remoteFunction = Comlink.wrap(new Worker("worker.js"));
await remoteFunction(Comlink.proxy(callback));
}
init();
```
for example I call this but it does not execute
Contributor guide
Assessment
This issue has not been assessed yet.