comlink
comlink copied to clipboard
Feature Request: Expose endpoint
Related to #372
Although there are ways of getting around this, it would make things much more convenient to expose the endpoint on a proxy property. I'm using comlink-loader, which makes it impossible to access the original WebWorker instance.
What I'd love is something like:
import { endpointMarker } from 'comlink'
import myProxy from 'webpack/magic/here'
// do a long job...
myProxy.doStuff().then(...)
// oops i want to cancel
let worker = myProxy[endpointMarker]
worker.terminate()
I imagine this would be easy enough to implement. Hoping you think so too! :)
That should definitely be easy. I am now wondering if I should remove createEndpoint
and put have it as a tree-shakeable duplicateEndpoint
or something and add this one in instead :thinking:
Lemme think about this for a bit.
Any updates on this?
Check the pull request I just submitted https://github.com/GoogleChromeLabs/comlink/pull/487
it'll allow to simply do :
myProxy.terminate();
After @surma 's review of my first attempt, I've built this one on comlink-loader https://github.com/GoogleChromeLabs/comlink-loader/pull/27.
Still waiting for it to be approved or rejected though