developit / workerize-loader

🏗️ Automatically move a module into a Web Worker (Webpack loader)
https://npm.im/workerize-loader
2.31k stars 86 forks source link

Support for async generators #81

Closed egriff38 closed 4 years ago

egriff38 commented 4 years ago

Hello, I was wondering how feasable it would be to add async generator support to web workers? I think using async function* and for await() would be an absolutely astounding way to utilized workers as streams rather than just one-off async functions. The hardest part I would imagine would be facilitating the connection between a specific generator instance in the worker vs the main thread.

developit commented 4 years ago

Just a note - comlink-loader is available and handles async generators in addition to most other interfaces. It's API is pretty similar to this loader.

egriff38 commented 4 years ago

Looks great. Thanks!