-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow creation of Observable from EventSource (server-sent events): enhancement #1644
Comments
Where is the documenation for the "from" operator? The following link: from-static-method just links to the top of the page... |
@balteo Please consider documentation is not complete, still being evolved over time. For |
Hi OJ Kwon, 2016-04-25 9:29 GMT+02:00 OJ Kwon notifications@github.com:
|
: not yet, sorry for confusion. |
No problems. I'll wait for it to be available. Any timeframe? 2016-04-25 9:38 GMT+02:00 OJ Kwon notifications@github.com:
|
I am also interested in seeing this ported to 5.0. Maybe @mattpodwysocki can help us here? |
+1 |
@mattpodwysocki Are PRs welcome for this? |
I would think that a PR is welcome for this @mattbrunetti, go for it! If it doesn't get accepted, we can always make it a separate node package. |
I don't think we want to support this in the core library right now. There are probably other implementations floating around in user land. Basically, you'd need to do something like this: function fromEventSource(url: string): Observable<MessageEvent> {
return new Observable<MessageEvent>(subscriber => {
const sse = new EventSource(url);
sse.onmessage = e => subscriber.next(e);
sse.onerror = e => subscriber.error(e);
return () => {
if (see.readyState === 1) {
sse.close();
}
};
} However, if you wanted to use the special handling EventSource has for events with an const sse = new EventSource(url);
fromEvent(sse, 'myeventhere').subscribe(console.log); |
RxJS version: 5.0.0-beta.1
Additional information: This is a request for enhancement.
It would be nice to have an operator to create Observables from EventSources from server-sent events.
Is is planned for a future version of RxJS? If so in which version?
If that feature is already available, maybe a relevant section could be added to the documentation.
The text was updated successfully, but these errors were encountered: