mojito-cache
Advanced tools
Comparing version 0.0.3 to 0.0.5
{ | ||
"name": "mojito-cache", | ||
"version": "0.0.3", | ||
"version": "0.0.5", | ||
"description": "A set of libraries for various caching strategies in mojito.", | ||
@@ -5,0 +5,0 @@ "main": " ", |
@@ -6,3 +6,3 @@ /* | ||
*/ | ||
/*jslint nomen: true, indent: 4*/ | ||
/*jslint nomen: true, indent: 4, plusplus: true*/ | ||
/*global YUI, YUITest */ | ||
@@ -17,10 +17,14 @@ | ||
var staticAppConfig; | ||
var staticAppConfig, | ||
refreshedAddons; | ||
this.dispatch = function (command, adapter) { | ||
var refreshedAddons, | ||
cache, | ||
var cache, | ||
cachedResource, | ||
newCommand, | ||
i, | ||
addonName, | ||
addonInstance, | ||
AddonConstuct, | ||
freshInstance = command.instance; | ||
@@ -32,3 +36,2 @@ | ||
if (!adapter.req.globals['request-cache']) { | ||
adapter.req.globals['request-cache'] = { | ||
@@ -48,3 +51,6 @@ byBase: {}, | ||
staticAppConfig = staticAppConfig || this.store.getStaticAppConfig(); | ||
if (!refreshedAddons) { | ||
staticAppConfig = this.store.getStaticAppConfig(); | ||
refreshedAddons = staticAppConfig['request-cache'] && staticAppConfig['request-cache'].refreshAddons; | ||
} | ||
@@ -55,23 +61,20 @@ newCommand = cachedResource.actionContext.command; | ||
newCommand.params = command.params; | ||
// This is specific to mojito-pipeline | ||
newCommand.task = command.task; | ||
Y.mix(newCommand.instance.config, command.instance.config, true); | ||
// Instantiate again the addons that need to be refreshed | ||
refreshedAddons = staticAppConfig['request-cache'] && staticAppConfig['request-cache'].refreshAddons; | ||
refreshedAddons.forEach(function (addonName) { | ||
for (i = 0; i < refreshedAddons.length; i++) { | ||
AddonConstuct = Y.mojito.addons.ac[refreshedAddons[i]]; | ||
var addonInstance, | ||
AddonConstuct = Y.mojito.addons.ac[addonName]; | ||
if (AddonConstuct) { | ||
addonInstance = new AddonConstuct(newCommand, adapter, cachedResource.actionContext); | ||
if (addonInstance.namespace && cachedResource.actionContext[addonInstance.namespace]) { | ||
cachedResource.actionContext[addonInstance.namespace] = addonInstance; | ||
} | ||
} | ||
}); | ||
} | ||
@@ -85,7 +88,5 @@ // The adapter and its callbacks need to be refreshed | ||
if (Y.Lang.isFunction(cachedResource.controller[newCommand.action])) { | ||
cachedResource.controller[newCommand.action](cachedResource.actionContext); | ||
} | ||
} else { | ||
// Expands the command.instance and creates a new AC | ||
@@ -121,6 +122,4 @@ // which in turn instanciates all the addons and calls the controller | ||
if (instance.base) { | ||
cache.byBase[instance.base] = newExpandedResource; | ||
} else if (instance.type) { | ||
cache.byType[instance.type] = newExpandedResource; | ||
@@ -127,0 +126,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15823
317