Skip to content

Commit 525ed70

Browse files
keithamuskoddsson
andauthored
Apply suggestions from code review
Co-authored-by: Kristján Oddsson <koddsson@gmail.com>
1 parent 6495727 commit 525ed70

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

docs/_guide/patterns.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class RemoveSearchElement extends HTMLElement {
7373

7474
### Registering global or many event listeners
7575

76-
Generally speaking, you'll want to use ["Actions"]({{ site.baseurl }}/guide/actions) to register event listeners with your Controller, but Actions only work for components nested within your Controller. It may also be necessary to listen for events on the Document, Window, or across well-known adjacent elements. We can manually call `addEventListener` for these types, including during the `connectedCallback` phase. Cleanup for `addEventListener` can be a bit error prone, but `AbortController` can be useful here to pass a signal that the element is cleaning up:
76+
Generally speaking, you'll want to use ["Actions"]({{ site.baseurl }}/guide/actions) to register event listeners with your Controller, but Actions only work for components nested within your Controller. It may also be necessary to listen for events on the Document, Window, or across well-known adjacent elements. We can manually call `addEventListener` for these types, including during the `connectedCallback` phase. Cleanup for `addEventListener` can be a bit error prone, but [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) can be useful here to pass a signal that the element is cleaning up:
7777

7878

7979
```typescript
@@ -99,7 +99,8 @@ class UnsavedChangesElement extends HTMLElement {
9999
}
100100

101101
handleEvent(event) {
102-
// ...
102+
// `handleEvent` will be called when each one of the event listeners
103+
// defined in `connectedCallback` is dispatched.
103104
}
104105
}
105106
```

0 commit comments

Comments
 (0)