| Constant | Defined By | ||
|---|---|---|---|
| aop : Function
Creates a Function who execute a specific function between two others. | core.functors | ||
| bind : Function
Wraps the function in another, locking its execution scope to a specific object. | core.functors | ||
| aop | Constant |
public const aop:FunctionCreates a Function who execute a specific function between two others.
Example :
import core.functors.aop ;
function sum(x:Number, y:Number):Number
{
trace("calculating...")
return x + y;
}
function begin():void
{
trace("begin");
}
function end():void
{
trace("end");
}
var result:Number = aop(sum, begin, end)(3, 5) ;
trace( result ) ;
| bind | Constant |
public const bind:FunctionWraps the function in another, locking its execution scope to a specific object.
Example :
import core.dump ;
import core.functors.bind ;
var action = function( ...arguments:Array ):void
{
trace( this + " :: " + core.dump( arguments ) ) ;
}
var proxy:Function ;
var scope:Object =
{
toString : function():String
{
return "scope" ;
}
};
action( 1 , 2 , 3 ) ; // [object global] :: [1,2,3]
proxy = bind( action , scope ) ;
proxy( 1 , 2 , 3 ) ; // scope :: [1,2,3]
proxy = bind( action , scope , 4, 5, 6) ;
proxy( 1 , 2 , 3 ) ; // scope :: [4,5,6,1,2,3]