Permalink
Browse files

REALTIME: limit the events to the ones that matter, add in instance e…

…vents
  • Loading branch information...
1 parent 83ceaa2 commit f323a44ec5b8664bfd3895adb74abbce4094790a Techwraith committed Oct 17, 2012
Showing with 14 additions and 12 deletions.
  1. +14 −12 lib/app.js
View
@@ -244,25 +244,27 @@ var App = function () {
console.log(geddy.model.descriptionRegistry);
var events = [
- 'beforeCreate'
- , 'create'
- , 'beforeValidate'
- , 'validate'
- , 'beforeUpdateProperties'
- , 'updateProperties'
, 'beforeSave'
- , 'save'
, 'beforeUpdate'
- , 'update'
, 'beforeRemove'
- , 'remove'
]
, registerEventListener = function (model, event) {
geddy.model[model].on(event, function (data) {
- data.model = model;
- data.event = event;
- geddy.io.sockets.emit(model+'#'+event, data);
+ var id;
+
+ event = event.replace('before','').toLowerCase();
+
+ if (typeof data == 'object') {
+ data.model = model;
+ data.event = event;
+ id = data.id;
+ }
+ else {
+ id = data;
+ }
+ geddy.io.sockets.emit(model+':'+event, data);
+ geddy.io.sockets.emit(model+':'+event+':'+id, data);
});
}

0 comments on commit f323a44

Please sign in to comment.