Skip to content

Instantly share code, notes, and snippets.

@dalsgaard
Created July 12, 2010 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dalsgaard/472184 to your computer and use it in GitHub Desktop.
Save dalsgaard/472184 to your computer and use it in GitHub Desktop.
var sys = require('sys');
var http = require('http');
var host = '127.0.0.1';
var couch = http.createClient(5984, host);
var listen = function() {
sys.log("listening");
var request = couch.request('GET', '/demo/_changes?feed=continuous', {'host': host});
request.end();
request.addListener('response', function (response) {
if (response.statusCode == 200) {
response.setEncoding('utf8');
response.addListener('data', function (chunk) {
sys.log(chunk);
});
response.addListener('end', listen);
} else {
setTimeout(listen, 5000);
}
});
};
listen();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment