Model Cache updates models on mutation

This commit is contained in:
Pete Richards 2016-11-08 13:54:31 -08:00
parent 0578a651da
commit 9a7f69a614
2 changed files with 10 additions and 2 deletions

View File

@ -372,7 +372,10 @@ define([
"services": [
{
"key": "cacheService",
"implementation": ModelCacheService
"implementation": ModelCacheService,
"depends": [
"topic"
]
},
{
"key": "now",

View File

@ -28,8 +28,13 @@ define([], function () {
* @constructor
* @memberof platform/core
*/
function ModelCacheService() {
function ModelCacheService(topic) {
this.cache = {};
topic('mutation').listen(function (domainObject) {
if (this.has(domainObject.getId())) {
this.put(domainObject.getId(), domainObject.getModel());
}
}.bind(this));
}
/**