Skip to content

Instantly share code, notes, and snippets.

@tomkersten
Created November 9, 2011 08:00
Show Gist options
  • Save tomkersten/1350790 to your computer and use it in GitHub Desktop.
Save tomkersten/1350790 to your computer and use it in GitHub Desktop.
h1 Pub/Sub Updates
ul.data
!!!
html
head
title SSEs, Node.js, and Redis
link(rel='stylesheet', href='/stylesheets/style.css')
body
!= body
script(src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js')
script(src='http://jquery-json.googlecode.com/files/jquery.json-2.2.min.js')
script(type='text/javascript')
var source = new EventSource('/update-stream');
source.addEventListener('message', function(e) {
console.log(e);
$('ul').append('<li>' + e.data + ' (message id: ' + e.lastEventId + ')</li>');
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment