examples/chatroom/models/thread.js
function(onLoad) {

            // create the collection immediately so we only
            // apply an update to an existing collection (Users)
            // whenever messages changes
            var users = app.models.Users();

            // pluck participants from the messages & update users
            caplet.watchProperty(this, "messages", function(messages) {
                
                var participants = [];
                var used         = {};

                messages.forEach(function(message) {
                    if (used[message.userId]) return;
                    used[message.userId] = 1;
                    participants.push({ uid: message.userId });
                });

                users.set("data", participants);
                this.set("participants", users);
            }).trigger();
        }
function(onLoad) {

            // create the collection immediately so we only
            // apply an update to an existing collection (Users)
            // whenever messages changes
            var users = app.models.Users();

            // pluck participants from the messages & update users
            caplet.watchProperty(this, "messages", function(messages) {
                
                var participants = [];
                var used         = {};

                messages.forEach(function(message) {
                    if (used[message.userId]) return;
                    used[message.userId] = 1;
                    participants.push({ uid: message.userId });
                });

                users.set("data", participants);
                this.set("participants", users);
            }).trigger();
        }
function ( onLoad ) { // create the collection immediately so we only // apply an update to an existing collection (Users) // whenever messages changes var users = app . models . Users ( ) ; // pluck participants from the messages & update users caplet . watchProperty ( this , "messages" , function ( messages ) { var participants = [ ] ; var used = { } ; messages . forEach ( function ( message ) { if ( used [ message . userId ] ) return ; used [ message . userId ] = 1 ; participants . push ( { uid : message . userId } ) ; } ) ; users . set ( "data" , participants ) ; this . set ( "participants" , users ) ; } ) . trigger ( ) ; }
start computing participants
start computing participants