source: Dev/branches/rest-dojo-ui/client/dojox/lang/aspect/memoizerGuard.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

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