Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 1.7 KB

fromeventsource.md

File metadata and controls

52 lines (37 loc) · 1.7 KB

Rx.DOM.fromEventSource(url, [openObserver])

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.

Arguments

  1. url (String): The URL of the Server-Side Events.
  2. [openObserver] (Rx.Observer): An optional Observer to capture the open event.

Returns

(Observable): An observable sequence which represents the data from a server-side event.

Example

// 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);
});

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: