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

Convert createClient internals to a class #46

Merged
merged 4 commits into from
Nov 4, 2024

Conversation

mthadley
Copy link
Contributor

@mthadley mthadley commented Nov 1, 2024

This class fulfills the same interface that the previous anonymous object returned by createClient did, so these should not be a breaking change.

In the future, we may want to consider removing createClient completely and have callers instantiate Client directly (or maybe call a factory/static method like Client.initialize).

#state: State;
#refreshTimer: ReturnType<typeof setTimeout> | undefined;

readonly #clientId: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Browser support for private methods in JavaScript itself is pretty good, but we also don't need to worry about it yet since our tsconfig targets es2020, which means the resulting code doesn't actually make use of this exact syntax yet.

But either way we should be getting pretty good runtime privacy (as opposed to only compile time via the TypeScript private), since the compiler generates pretty interesting code. Worth glancing through dist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been curious about browser support, but it's cool to see the polyfill code too.

@mthadley mthadley marked this pull request as ready for review November 4, 2024 19:15
Copy link
Collaborator

@cmatheson cmatheson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

niiiiiiice. i haven't ever used the #private syntax. A+.

@mthadley mthadley merged commit 5f81fe1 into main Nov 4, 2024
1 check passed
@mthadley mthadley deleted the convert-create-client-internals-to-class branch November 4, 2024 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants