Built motion from commit 5e31ea4.|0.0.32
[motion.git] / server / api / thing / thing.socket.js
1 /**
2  * Broadcast updates to client when the model changes
3  */
4
5 'use strict';
6
7 //var thing = require('./thing.model');
8 var thing = require('../../models').Thing;
9
10 exports.register = function (socket) {
11
12   thing.afterCreate(function (doc) {
13     onSave(socket, doc);
14   });
15
16   thing.afterDestroy(function (doc) {
17     onRemove(socket, doc);
18   });
19 }
20
21 function onSave(socket, doc, cb) {
22   socket.emit('thing:save', doc);
23 }
24
25 function onRemove(socket, doc, cb) {
26   socket.emit('thing:remove', doc);
27 }