-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcfadf3
commit 0e79a9f
Showing
16 changed files
with
1,144 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# EventSource | ||
|
||
Undici exposes a WHATWG spec-compliant implementation of [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) | ||
for [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events). | ||
|
||
## Instantiating EventSource | ||
|
||
Undici exports a EventSource class. You can instantiate the EventSource as | ||
follows: | ||
|
||
```mjs | ||
import { EventSource } from 'undici' | ||
|
||
const evenSource = new EventSource('http://localhost:3000') | ||
evenSource.onmessage = (event) => { | ||
console.log(event.data) | ||
} | ||
``` | ||
|
||
More information about the EventSource API can be found on | ||
[MDN](https://developer.mozilla.org/en-US/docs/Web/API/EventSource). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.