- From: Caleb Williams <notifications@github.com>
- Date: Fri, 28 Jun 2019 12:18:26 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 28 June 2019 19:18:49 UTC
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