dojox.lang.aspect (version 1.5)

Object » dojox.lang.aspect

Method Summary

Methods

dojox.lang.aspect.advise
Returns Object

Attaches AOP-style advices to a method. Can attach several advices at once and operate on several methods of an object. The latter is achieved when a RegExp is specified as a method name, or an array of strings and regular expressions is used. In this case all functional methods that satisfy the RegExp condition are processed. This function returns a handle, which can be used to unadvise, or null, if advising has failed. This function is a convenience wrapper for dojox.lang.aspect.adviseRaw().

ParameterTypeDescription
objObjectA source object for the advised function. Cannot be a DOM node. If this object is a constructor, its prototype is advised.
methodString|RegExp|ArrayA string name of the function in obj. In case of RegExp all methods of obj matching the regular expression are advised.
adviceObject|Function|ArrayAn object, which defines advises, or a function, which returns such object, or an array of previous items. The advice object can define following member functions: before, around, afterReturning, afterThrowing, after. If the function is supplied, it is called with a context object once per call to create a temporary advice object, which is destroyed after the processing. The temporary advice object can implement a destroy() method, if it wants to be called when not needed.
dojox.lang.aspect.adviseRaw
Returns Object

Attaches AOP-style advices to object's methods. Can attach several advices at once and operate on several methods of the object. The latter is achieved when a RegExp is specified as a method name. In this case all functional methods that satisfy the RegExp condition are processed. This function returns a handle, which can be used to unadvise, or null, if advising has failed.

ParameterTypeDescription
objObjectA source object for the advised function. Cannot be a DOM node.
methodsArrayAn array of method names (strings) to be advised.
advicesArrayAn array of advices represented by objects or functions that return such objects on demand during the event processing. The advice object can define following member functions: before, around, afterReturning, afterThrowing, after. If the function is supplied, it is called with a context object once per call to create a temporary advice object, which is destroyed after the processing. The temporary advice object can implement a destroy() method, if it wants to be called when not needed.
dojox.lang.aspect.cflow
Returns Boolean
Returns true if the context stack contains a context for a given instance that satisfies a given method name criteria.
ParameterTypeDescription
instanceObjectAn instance to be matched. If null, any context will be examined. Otherwise the context should belong to this instance.
methodString|RegExp|Array
Optional.
An optional pattern to be matched against a method name. Can be a string, a RegExp object or an array of strings and RegExp objects. If it is omitted, any name will satisfy the criteria.
dojox.lang.aspect.counter
Returns Object
Returns an object, which can be used to count calls to methods.
dojox.lang.aspect.getContext
Returns Object
Returns the context information for the advice in effect.
dojox.lang.aspect.getContextStack
Returns Array
Returns the context stack, which reflects executing advices up to this point. The array is ordered from oldest to newest. In order to get the active context use dojox.lang.aspect.getContext().
dojox.lang.aspect.memoizer
Returns Object
Returns an object, which can be used to count calls to methods.
ParameterTypeDescription
keyMakerFunction
Optional.
the function, which takes method's arguments and returns a key, which can be used to index the result.
dojox.lang.aspect.memoizerGuard
Returns Object
Invalidates the memoizer's cache (see dojox.lang.aspect.memoizer) after calling certain methods.
ParameterTypeDescription
methodString|Array
Optional.
Optional method's name to be guarded: only cache for this method will be invalidated on call. Can be a string or an array of method names. If omitted the whole cache will be invalidated.
dojox.lang.aspect.proceed

Calls the original function (or the next level around advice). Accepts and passes on any number of arguments, and returns a value. This function is valid only in the content of around calls.

dojox.lang.aspect.profiler
Returns Object
Returns an object, which can be used to time calls to methods.
ParameterTypeDescription
titleString
Optional.
The optional name of the profile section.
dojox.lang.aspect.timer
Returns Object
Returns an object, which can be used to time calls to methods.
ParameterTypeDescription
nameString
Optional.
The optional unique name of the timer.
dojox.lang.aspect.tracer
Returns Object
Returns an object, which can be used to trace calls with Firebug's console. Prints argument, a return value, or an exception.
ParameterTypeDescription
groupingBooleanThe flag to group output. If true, indents embedded console messages.
dojox.lang.aspect.unadvise
Detach previously attached AOP-style advices.
ParameterTypeDescription
handleObjectThe object returned by dojox.lang.aspect.advise().

Comments