Skip to content

Commit 33fb4e7

Browse files
committed
docs: clarify using defineObservedAttributes usage
1 parent 7aa5841 commit 33fb4e7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

docs/_guide/attrs.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ class HelloWorldElement extends HTMLElement {
175175

176176
### What about without Decorators?
177177

178-
If you're not using decorators, then you won't be able to use the `@attr` decorator, but there is still a way to achieve the same result. Under the hood `@attr` simply tags a field, but `initializeAttrs` does all of the logic.
178+
If you're not using decorators, then you won't be able to use the `@attr` decorator, but there is still a way to achieve the same result. Under the hood `@attr` simply tags a field, but `initializeAttrs` and `defineObservedAttributes` do all of the logic.
179179

180-
Calling `initializeAttrs` in your connected callback, with the list of properties you'd like to initialize can achieve the same result. The class fields can still be defined in your class, and they'll be overridden as described above. For example:
180+
Calling `initializeAttrs` in your connected callback, with the list of properties you'd like to initialize, and calling `defineObservedAttributes` with the class, can achieve the same result as `@attr`. The class fields can still be defined in your class, and they'll be overridden as described above. For example:
181181

182182
```js
183-
import {initializeAttrs} from '@github/catalyst'
183+
import {initializeAttrs, defineObservedAttributes} from '@github/catalyst'
184184

185185
class HelloWorldElement extends HTMLElement {
186186
foo = 1
@@ -190,6 +190,7 @@ class HelloWorldElement extends HTMLElement {
190190
}
191191

192192
}
193+
defineObservedAttributes(HelloWorldElement, ['foo'])
193194
```
194195

195196
This example is functionally identical to:

0 commit comments

Comments
 (0)