diff options
author | Victor Woeltjen <victor.woeltjen@nasa.gov> | 2016-11-08 02:33:28 +0300 |
---|---|---|
committer | Victor Woeltjen <victor.woeltjen@nasa.gov> | 2016-11-08 02:35:38 +0300 |
commit | d1d875463a8db74fc17b9c15b396006d05380608 (patch) | |
tree | 9a08b125e8142c22e4b4b42721e5780da61ee4b5 | |
parent | 6738e6bc97786fc38b359f29b144b2c6a95ce832 (diff) |
[Models] Broadcast events on persist/refreshwalkers-1306
-rw-r--r-- | platform/core/bundle.js | 2 | ||||
-rw-r--r-- | platform/core/src/capabilities/PersistenceCapability.js | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/platform/core/bundle.js b/platform/core/bundle.js index f60310ad1..0105ac100 100644 --- a/platform/core/bundle.js +++ b/platform/core/bundle.js @@ -336,7 +336,7 @@ define([ "key": "persistence", "implementation": PersistenceCapability, "depends": [ - "cacheService", + "topic", "persistenceService", "identifierService", "notificationService", diff --git a/platform/core/src/capabilities/PersistenceCapability.js b/platform/core/src/capabilities/PersistenceCapability.js index 54fa537c6..74c8b24c7 100644 --- a/platform/core/src/capabilities/PersistenceCapability.js +++ b/platform/core/src/capabilities/PersistenceCapability.js @@ -42,7 +42,7 @@ define( * @implements {Capability} */ function PersistenceCapability( - cacheService, + topic, persistenceService, identifierService, notificationService, @@ -53,7 +53,7 @@ define( this.modified = domainObject.getModel().modified; this.domainObject = domainObject; - this.cacheService = cacheService; + this.topic = topic; this.identifierService = identifierService; this.persistenceService = persistenceService; this.notificationService = notificationService; @@ -110,6 +110,7 @@ define( */ PersistenceCapability.prototype.persist = function () { var self = this, + persistenceTopic = this.topic('persistence'), domainObject = this.domainObject, model = domainObject.getModel(), modified = model.modified, @@ -135,6 +136,9 @@ define( domainObject.getModel() ]).then(function (result) { return rejectIfFalsey(result, self.$q); + }).then(function (result) { + persistenceTopic.notify(domainObject); + return result; }).catch(function (error) { return notifyOnError(error, domainObject, self.notificationService, self.$q); }); @@ -148,6 +152,7 @@ define( */ PersistenceCapability.prototype.refresh = function () { var domainObject = this.domainObject; + var refreshTopic = this.topic('refresh'); // Update a domain object's model upon refresh function updateModel(model) { @@ -164,7 +169,10 @@ define( return this.persistenceService.readObject( this.getSpace(), this.getKey() - ).then(updateModel); + ).then(updateModel).then(function (result) { + refreshTopic.notify(domainObject); + return result; + }); }; /** |