Created
November 9, 2011 08:00
-
-
Save tomkersten/1350790 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 Pub/Sub Updates | |
ul.data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! | |
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