Re: [w3c/webcomponents] [idea] Expose and API for syncing attributes and properties (#823)

I definitely think a decorator is a good choice here, but really don't like the built-in modules (I personally think that proposal is just unnecessary abstraction, but that's just me).

Could that be put inside of something like `customElements` instead?

```javascript
const { reflect } = customElements;

class MyElement extends HTMLElement {
  @reflect({ name: 'my-attr' }) myAttr;
}
```

As for the property change callback, I am happy with just using setters, but even using the example you put forward, you could drop an updated callback inside the decorator invocation:

```javascript
const { reflect } = customElements;

class MyElement extends HTMLElement {
  @reflect({ 
    name: 'my-attr',
    callback: this.#updateMyAttr.bind(this)
   }) myAttr;

  #updateMyAttr(value, prop) { /** Do something really interesting */ }
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/823#issuecomment-506848512

Received on Friday, 28 June 2019 19:18:49 UTC