Skip to content

Commit

Permalink
docs: recommend using Microsoft's fetch-event-source
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Sep 16, 2024
1 parent 849c7b3 commit 2ccc32f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/ecosystem/awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

## Useful Related Libraries

* [Microsoft's Fetch Event Source, a better JavaScript API for making Event Source requests](https://github.com/Azure/fetch-event-source)
* [`EventSource` polyfill for Edge/IE and old browsers](https://github.com/Yaffle/EventSource)
* [`EventSource` polyfill for React Native](https://github.com/jordanbyron/react-native-event-source)
* [`EventSource` implementation for Node](https://github.com/EventSource/eventsource)
Expand Down
4 changes: 3 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const eventSource = new EventSource(url);
eventSource.onmessage = e => console.log(e); // do something with the payload
```

The `EventSource` class is available [in all modern web browsers](https://caniuse.com/eventsource). And for legacy browsers, [there are polyfills](ecosystem/awesome.md#useful-related-libraries).
The `EventSource` class is available [in all modern web browsers](https://caniuse.com/eventsource).

Although the native `EventSource` class is generally quite good, we recommend [Microsoft's `fetch-event-source` library](https://github.com/Azure/fetch-event-source) for advanced use cases, as it allows finer-grained error handling and supports authentication via the `Authorization` header.

## Closing Connection

Expand Down
2 changes: 1 addition & 1 deletion docs/mercure.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A free (as in beer, and as in speech) reference server, a commercial High Availa
* designed with [hypermedia in mind](https://en.wikipedia.org/wiki/HATEOAS), also supports [GraphQL](https://graphql.org/)
* auto-discoverable through [web linking](https://tools.ietf.org/html/rfc5988)
* message encryption support
* can work with old browsers (IE7+) using an `EventSource` polyfill
* can work with old browsers (IE7+) using [an `EventSource` polyfill](ecosystem/awesome.md#useful-related-libraries)
* [connection-less push](https://html.spec.whatwg.org/multipage/server-sent-events.html#eventsource-push) in controlled environments (e.g. browsers on mobile handsets tied to specific carriers)

[Read the specification](../spec/mercure.md)
Expand Down

0 comments on commit 2ccc32f

Please sign in to comment.