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

[question] Why proxy instead of property list? #198

Open
Lodin opened this issue Jul 30, 2020 · 0 comments
Open

[question] Why proxy instead of property list? #198

Lodin opened this issue Jul 30, 2020 · 0 comments

Comments

@Lodin
Copy link

Lodin commented Jul 30, 2020

This library is amazing, and I'm going to use it for my next project. However, reading through docs and code, I found that it uses Proxy to observe property changes. I wonder why Proxy? I know proxies as quite slow and clunky solution which is barely polyfillable.

Why not use the explicit list of allowed properties, like it is done for attributes? It could look like the following:

customElements.define('my-profile', component(Profile, { properties: ['userData'] }));

function App() {
  const userData = useFictitiousUser();

  return html`
    <my-profile .userData=${userData}></my-profile>
  `;
}

This not only removes the need in Proxy at all but also gives us a clearer and more explicit API of the component that can be easily found in source code. It may also solve #168.

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

1 participant