This method wraps an EventSource as an observable sequence which is used to send server-side events. Note that your browser must support EventSource objects.
url
(String): The URL of the Server-Side Events.[openObserver]
(Rx.Observer
): An optional Observer to capture the open event.
(Observable
): An observable sequence which represents the data from a server-side event.
// Not handling the open event
var source = Rx.DOM.fromEventSource('foo.php');
source.subscribe(function (e) {
console.log('Received data: %s', e.data);
});
// Using an observer for the open
var observer = Rx.Observer.create(function (e) {
console.log('Opening');
});
var source = Rx.DOM.fromEventSource('foo.php', observer);
source.subscribe(function (e) {
console.log('Received data: ' + e.data);
});
File:
Dist:
Prerequisites:
NPM Packages:
NuGet Packages:
Unit Tests: