rails/rails — pull request #9427 by wangjohn (2013-02-26 02:47:35+00:00)
Title: Added javascript helpers which add event listeners to an EventSource.

This pull request adds an easy way to create a javascript tag that listens to an EventSource. I have also added methods to create strings containing javascript for adding event listeners to a source.

This helps for adding streaming SSEs to a rails app. You can now call the ```event_source_tag``` function and create javascript. For example:

```ruby
event_source_tag("sse_server", {"message" => "function(e) { console.log(e.data) }"})
```
will create a javascript tag with the following:

```javascript
if (!!window.EventSource){
var eventStream = new EventSource("sse_server");
eventStream.addListener('message', function(e) { console.log(e.data) }, false);
}
```