2 * Broadcast updates to client when the model changes
7 var Motionbar = require('../../models').Motionbar;
9 exports.register = function(socket) {
10 Motionbar.afterCreate(function(doc) {
13 Motionbar.afterDestroy(function(doc) {
14 onRemove(socket, doc);
18 function onSave(socket, doc, cb) {
19 // doc.UserId is string. You don't use ===
20 if (socket.userId == doc.UserId) {
21 socket.emit('motionbar:save', doc);
25 function onRemove(socket, doc, cb) {
26 socket.emit('motionbar:remove', doc);