ajax - CouchDB - Continuous feed using jQuery -
after reading similar questions here, i'm curious whether @ possible?
i understand can make below work, wrapping in setinterval function, repeatedly calls check-for-changes function, rather use continuous polling.
the database regularly gets updated every minute during peak times, seems waste keep polling database during off-peak times...
$.getjson('http://localhost:5984/db?callback=?', function(db) { console.log(db.update_seq); $.getjson('http://localhost:5984/db/_changes?since='+db.update_seq+'&feed=continuous&callback=?', function(changes) { console.log(changes); }); }); firebug shows when change indeed made, happens, null returned.
i'm on same domain, calling page localhost/index.php
rather using continuous or long-polling, instead adopt adaptive strategy. perhaps start @ 1 minute intervals. if there no updates, 2 minutes, 3, 4, 5 etc. if there updates interval can modified reflect time until next expected update.
basically boils down how important notifications of updates in near-real-time , how large delay willing deal with.
Comments
Post a Comment