Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Expose endpoint #405

Open
wellcaffeinated opened this issue Nov 22, 2019 · 4 comments
Open

Feature Request: Expose endpoint #405

wellcaffeinated opened this issue Nov 22, 2019 · 4 comments

Comments

@wellcaffeinated
Copy link

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! :)

@surma
Copy link
Collaborator

surma commented Nov 24, 2019

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 🤔

Lemme think about this for a bit.

@coolreader18
Copy link

Any updates on this?

@aelgasser
Copy link

Check the pull request I just submitted #487

it'll allow to simply do :

myProxy.terminate();

@aelgasser
Copy link

After @surma 's review of my first attempt, I've built this one on comlink-loader GoogleChromeLabs/comlink-loader#27.

Still waiting for it to be approved or rejected though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants