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

"Proxy" is a loaded term in the docs. Should be named Remote when referring to symbol methods #630

Open
ivancuric opened this issue Mar 7, 2023 · 1 comment

Comments

@ivancuric
Copy link

ivancuric commented Mar 7, 2023

Every proxy created by Comlink has the [releaseProxy]() method. Calling it will detach the proxy and the exposed object from the message channel, allowing both ends to be garbage collected.

However this isn't true. This won't work:

import { proxy, releaseProxy } from "comlink";

const proxied = proxy({});
proxy[releaseProxy]();

One would think that the return type of a proxy function would count as a proxy, but it's not.

Only Remote types have the ProxyMethods on them:
https://github.com/GoogleChromeLabs/comlink/blob/main/src/comlink.ts#LL138C8-L138C8

The docs should maybe say that every Remote created by a wrap has a [releaseProxy]() method.

@ivancuric ivancuric changed the title "Proxy" is a loaded term, especially considering releaseProxy. Should be named Remote. "Proxy" is a loaded term in the docs. Should be named Remote when referring to symbol methods Mar 7, 2023
@surma
Copy link
Collaborator

surma commented Mar 8, 2023

wrap() is what returns a proxy. `proxy() is just a marker function that says a value should be proxied across the boundary. You are right that the docs should be better here. I actually like the idea of adding types to the docs and using the type names to disambiguate.

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

2 participants