Skip to content

Commit

Permalink
#269 Update stream event generation to support firing events for sub …
Browse files Browse the repository at this point in the history
…objects
  • Loading branch information
nadouani committed Jul 27, 2017
1 parent e9a2482 commit b18ea3e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ui/app/scripts/services/StreamSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
var byRootIds = {};
var byObjectTypes = {};
var byRootIdsWithObjectTypes = {};
var bySecondaryObjectTypes = {};

angular.forEach(data, function(message) {
var rootId = message.base.rootId;
var objectType = message.base.objectType;
var rootIdWithObjectType = rootId + '|' + objectType;
var secondaryObjectTypes = message.summary ? _.without(_.keys(message.summary), objectType) : [];

if (rootId in byRootIds) {
byRootIds[rootId].push(message);
Expand All @@ -45,6 +48,15 @@
} else {
byRootIdsWithObjectTypes[rootIdWithObjectType] = [message];
}

_.each(secondaryObjectTypes, function(type) {
if (type in bySecondaryObjectTypes) {
bySecondaryObjectTypes[type].push(message);
} else {
bySecondaryObjectTypes[type] = [message];
}
});

});

angular.forEach(byRootIds, function(messages, rootId) {
Expand All @@ -53,6 +65,12 @@
angular.forEach(byObjectTypes, function(messages, objectType) {
self.runCallbacks('any', objectType, messages);
});

// Trigger strem event for sub object types
angular.forEach(bySecondaryObjectTypes, function(messages, objectType) {
self.runCallbacks('any', objectType, messages);
});

angular.forEach(byRootIdsWithObjectTypes, function(messages, rootIdWithObjectType) {
var temp = rootIdWithObjectType.split('|', 2),
rootId = temp[0],
Expand Down

0 comments on commit b18ea3e

Please sign in to comment.