From 4189a05758f928946594b0058e5ff540e6f170bf Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Thu, 4 Apr 2019 10:29:42 -0700 Subject: [PATCH] event emitter uses keystring instead of key, to avoid broadcasting to all domainObjects that share the same key' (#2350) --- src/adapter/services/LegacyObjectAPIInterceptor.js | 6 ++++-- src/api/objects/MutableObject.js | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/adapter/services/LegacyObjectAPIInterceptor.js b/src/adapter/services/LegacyObjectAPIInterceptor.js index 9f6aafcdc8..5c323c4de5 100644 --- a/src/adapter/services/LegacyObjectAPIInterceptor.js +++ b/src/adapter/services/LegacyObjectAPIInterceptor.js @@ -57,8 +57,10 @@ define([ }.bind(this); handleLegacyMutation = function (legacyObject) { - var newStyleObject = utils.toNewFormat(legacyObject.getModel(), legacyObject.getId()); - this.eventEmitter.emit(newStyleObject.identifier.key + ":*", newStyleObject); + var newStyleObject = utils.toNewFormat(legacyObject.getModel(), legacyObject.getId()), + keystring = utils.makeKeyString(newStyleObject.identifier); + + this.eventEmitter.emit(keystring + ":*", newStyleObject); this.eventEmitter.emit('mutation', newStyleObject); }.bind(this); diff --git a/src/api/objects/MutableObject.js b/src/api/objects/MutableObject.js index 110c256dbe..78feb6fc53 100644 --- a/src/api/objects/MutableObject.js +++ b/src/api/objects/MutableObject.js @@ -21,8 +21,10 @@ *****************************************************************************/ define([ + './object-utils.js', 'lodash' ], function ( + utils, _ ) { var ANY_OBJECT_EVENT = "mutation"; @@ -41,7 +43,9 @@ define([ } function qualifiedEventName(object, eventName) { - return [object.identifier.key, eventName].join(':'); + var keystring = utils.makeKeyString(object.identifier); + + return [keystring, eventName].join(':'); } MutableObject.prototype.stopListening = function () {