title: D3 Event Listener for Stream 'message' event
body: <p>Good day everyone, </p>
  
  <p>How is it possible to actually have a D3 element have a listener for an <code>EventSource</code> message event. The event is triggered by the HTML5 Streaming Event as described in <a href="http://www.html5rocks.com/en/tutorials/eventsource/basics/" rel="nofollow noreferrer">this</a> article. </p>
  
  <p>The Following is the event source:</p>
  
  <pre><code>...
  # generate event source
  if (!!window.EventSource)
  source = new EventSource('/stream?hashtags='+gon.hashtags)
  
  # Add event listener to stream source
  source.addEventListener('message',(e) -&gt; ??? , false)
  ...
  </code></pre>
  
  <p>The element that has a listener (different namespace, different file):</p>
  
  <pre><code># Create a square canvas with width equal to the div's width
  svg = d3.select('#d3-canvas').append('svg')
  .attr(
    width: w
    height: h
  )
  .on('message', () -&gt; alert 'test')
  .attr('id','d3-svg')
  </code></pre>
  
  <p>I want to have a D3 Layout listening and updating on new message with data send by the HTML5 stream. </p>
  
  <p>Any help maybe?</p>
  
  <p>Thanks a lot</p>