Skip to content

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

Open
@Lodin

Description

@Lodin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions