memoizerGuard.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // wrapped by build app
  2. define("dojox/lang/aspect/memoizerGuard", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){
  3. dojo.provide("dojox.lang.aspect.memoizerGuard");
  4. (function(){
  5. var aop = dojox.lang.aspect,
  6. reset = function(/*String|Array?*/ method){
  7. var that = aop.getContext().instance, t;
  8. if(!(t = that.__memoizerCache)){ return; }
  9. if(arguments.length == 0){
  10. delete that.__memoizerCache;
  11. }else if(dojo.isArray(method)){
  12. dojo.forEach(method, function(m){ delete t[m]; });
  13. }else{
  14. delete t[method];
  15. }
  16. };
  17. aop.memoizerGuard = function(/*String|Array?*/ method){
  18. // summary:
  19. // Invalidates the memoizer's cache (see dojox.lang.aspect.memoizer)
  20. // after calling certain methods.
  21. //
  22. // method:
  23. // Optional method's name to be guarded: only cache for
  24. // this method will be invalidated on call. Can be a string
  25. // or an array of method names. If omitted the whole cache
  26. // will be invalidated.
  27. return { // Object
  28. after: function(){ reset(method); }
  29. };
  30. };
  31. })();
  32. });