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