lib/Model.js
function Model(io, name, itemDef, modelDef, filter) {
    EventEmitter.call(this);

    //name = name.toLowerCase();

    this.io = io;
    this.name = name;
    this.url = utils.resolveName(name);
    this.itemDef = itemDef || {};
    this.modelDef = modelDef || {};
    this.filter = filter || {};
    this.children = [];
    this.eventHandlers = {};

    this.bindings = [];

    this.value = publicModel(this, new Promise(function(resolve, reject) {
        this.on('ready', resolve());
    }.bind(this)));

    this.on('created', this._onCreated.bind(this));
    this.on('updated', this._onUpdated.bind(this));
    this.on('destroyed', this._onDestroyed.bind(this));

    io.socket.on(name, function(message) {
        this.emit(message.verb, message);
    }.bind(this));

    this.refresh().then(function() {
        this.emit('ready');
    }.bind(this));
}
function Model(io, name, itemDef, modelDef, filter) {
    EventEmitter.call(this);

    //name = name.toLowerCase();

    this.io = io;
    this.name = name;
    this.url = utils.resolveName(name);
    this.itemDef = itemDef || {};
    this.modelDef = modelDef || {};
    this.filter = filter || {};
    this.children = [];
    this.eventHandlers = {};

    this.bindings = [];

    this.value = publicModel(this, new Promise(function(resolve, reject) {
        this.on('ready', resolve());
    }.bind(this)));

    this.on('created', this._onCreated.bind(this));
    this.on('updated', this._onUpdated.bind(this));
    this.on('destroyed', this._onDestroyed.bind(this));

    io.socket.on(name, function(message) {
        this.emit(message.verb, message);
    }.bind(this));

    this.refresh().then(function() {
        this.emit('ready');
    }.bind(this));
}
function Model ( io , name , itemDef , modelDef , filter ) { EventEmitter . call ( this ) ; //name = name.toLowerCase(); this . io = io ; this . name = name ; this . url = utils . resolveName ( name ) ; this . itemDef = itemDef || { } ; this . modelDef = modelDef || { } ; this . filter = filter || { } ; this . children = [ ] ; this . eventHandlers = { } ; this . bindings = [ ] ; this . value = publicModel ( this , new Promise ( function ( resolve , reject ) { this . on ( 'ready' , resolve ( ) ) ; } . bind ( this ) ) ) ; this . on ( 'created' , this . _onCreated . bind ( this ) ) ; this . on ( 'updated' , this . _onUpdated . bind ( this ) ) ; this . on ( 'destroyed' , this . _onDestroyed . bind ( this ) ) ; io . socket . on ( name , function ( message ) { this . emit ( message . verb , message ) ; } . bind ( this ) ) ; this . refresh ( ) . then ( function ( ) { this . emit ( 'ready' ) ; } . bind ( this ) ) ; }
An actual model that syncs with the server

This object contains the internal model representation, and updates any
objects bound to it.

@param {object} io the socket.io object
@param {string} name
@param itemDef {object?}
@param modelDef {object?}
@param filter {object?}
@constructor
An actual model that syncs with the server