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

Consider not using constructors for API proxy creation #1

Closed
justinfagnani opened this issue Sep 7, 2017 · 3 comments
Closed

Consider not using constructors for API proxy creation #1

justinfagnani opened this issue Sep 7, 2017 · 3 comments

Comments

@justinfagnani
Copy link

Just subjective opinion here, but a line like this:

    // Note the usage of `await`:
    const app = await new api.App();

is a little confusing to me - it makes me think that api.App is a Promise, but then what type does the Promise resolve? I know it's a thennable that returns itself, but I think that ability of thennables probably goes over most people's heads. I think it'd be a little clearer with just a factory method:

    // Note the usage of `await`:
    const app = await api.createApp();
@surma
Copy link
Collaborator

surma commented Sep 7, 2017

So would you disallow new altogether? It would make the RPC protocol a bit simpler 🤔

The more I worked with this, the more I have gotten to like await new ... as it works with the mantra: “Whenever you are touching a Comlink’d proxy, use await.”

But I see your point that when you are trying to actually unpack the data structure in your head, it might not make sense right away.

@surma
Copy link
Collaborator

surma commented Sep 7, 2017

Also GoogleChromeLabs/tasklets#9 might be relevant/of your interest

@surma
Copy link
Collaborator

surma commented Nov 9, 2017

Gonna close this for now :)

@surma surma closed this as completed Nov 9, 2017
felixfbecker pushed a commit to felixfbecker/comlink that referenced this issue Feb 19, 2019
surma pushed a commit that referenced this issue May 11, 2019
surma pushed a commit that referenced this issue Nov 19, 2019
…ethod-types

Add types for symbol methods
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