Created
March 2, 2011 11:00
-
-
Save tmzt/850776 to your computer and use it in GitHub Desktop.
models.js
This file contains 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
module.exports = function(path, callback) { | |
/* ... */ | |
models = require('models'); | |
//models.UnreadClippings.count = models.UnreadClippings.count.bind(models.UnreadClippings); | |
models.UnreadClippings.incr = models.UnreadClippings.incr.bind(models.UnreadClippings); | |
/* express routes */ | |
callback(app, models); }; |
This file contains 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
var cluster = require('./cluster'); | |
var http = require('http'); | |
var connect = require('connect'); | |
var dnode = require('dnode'); | |
var development = require('./development/app.js'); | |
development(__dirname + '/development', function(server, models) { | |
cluster(server).use(cluster.debug()).listen(8033); | |
dnode(function(c){ | |
this.UnreadClippings = models.UnreadClippings; | |
}).listen({protocol: 'socket.io', server: server, transports: ['xhr-polling']}); | |
}); | |
This file contains 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
function UnreadClippings() { | |
console.log('this: ', this); | |
this._count = 0; | |
this.queue = []; | |
this.updateclient = function(count) { console.log('queueing update: ', count); this.queue.push({'type': 'updt', 'count':this._count});}; | |
this.incr = function() { | |
this._count++; | |
console.log('incr() this.updateclient: ', this.updateclient); | |
if (this.updateclient) { | |
this.updateclient(this._count); | |
}; | |
}; | |
this.init = function(updateclient) { | |
console.log('init() this: ', this); | |
this.updateclient = updateclient; | |
}; | |
}; | |
module.exports.UnreadClippings = new UnreadClippings(); | |
console.log('_count: ', module.exports.UnreadClippings._count); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment