Using comlink with GoogleChromeLabs/worker-plugin
See original GitHub issueHi team, love your work. Having some trouble integrating google’s worker plugin.
main.ts
void async function() {
const worker = new Worker('./test.js', { type: 'module' })
const TestStore = Comlink.wrap(worker)
console.log(await new TestStore())
}()
test.js
import { expose } from 'comlink'
class Thing {
constructor() {
this.state = ''
}
setState(v) {
this.state = v
}
}
expose(Thing)
results in the error
Uncaught (in promise) TypeError: Cannot read property 'apply' of undefined
at MessagePort.eval
I am using the latest Chrome
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:14
Top Results From Across the Web
Integrating web workers in a React app with Comlink
Google's Comlink library makes interacting with web workers much more elegant. Explore a real-world use case by integrating a web worker ...
Read more >Simplify Web Worker code with Comlink - David East
But if workers are so great, why are they so under utilized? Are UI performance issues not common? That can't be the case...
Read more >How to use the comlink.expose function in comlink - Snyk
To help you get started, we've selected a few comlink examples, based on popular ways it is used in public projects. Secure your...
Read more >Enjoyable WebWorkers in Angular. With Comlink - Medium
Angular CLI v8.3 supports Web Worker module as a built-in feature! ... Comlink has its own TypeScript definition in the package, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
能将解一下如何在React项目中使用它吗
This error is also there with worker-loader