Skip to content

Commit 715f193

Browse files
committed
Document events and [loading] state
1 parent cd083b7 commit 715f193

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,35 @@ import '@github/remote-input-element'
3030
<div id="md-preview"></div>
3131
```
3232

33+
### Styling loading state
34+
35+
`[loading]` attribute will be added to `<remote-input>` when a network request is kicked off, and removed when it ends.
36+
37+
```css
38+
.loading-icon { display: none; }
39+
remote-input[loading] .loading-icon { display: inline; }
40+
```
41+
42+
### Events
43+
44+
```js
45+
const remoteInput = document.querySelector('remote-input')
46+
47+
// Network request lifecycle events.
48+
remoteInput.addEventListener('loadstart', function(event) {
49+
console.log('Network request started', event)
50+
})
51+
remoteInput.addEventListener('loadend', function(event) {
52+
console.log('Network request complete', event)
53+
})
54+
remoteInput.addEventListener('load', function(event) {
55+
console.log('Network request succeeded', event)
56+
})
57+
remoteInput.addEventListener('error', function(event) {
58+
console.log('Network request failed', event)
59+
})
60+
```
61+
3362
## Browser support
3463

3564
Browsers without native [custom element support][support] require a [polyfill][].

0 commit comments

Comments
 (0)