Class: AOP

AOP(objnon-null, fnNamenon-null)

AOP class

Constructor

new AOP(objnon-null, fnNamenon-null)

Constructor for AOP class.
Parameters:
Name Type Description
obj Object The object containing the displaced function.
fnName string The name of the displaced function.
Source:

Members

(protected, non-null) after_ :Array

Array of listeners that will invoke after the displaced function.
Type:
  • Array
Source:

(protected, non-null) before_ :Array

Array of listeners that will invoke before the displaced function.
Type:
  • Array
Source:

(protected) fn_ :function

The displaced function.
Type:
  • function
Source:

(protected) fnName_ :string

The name of the displaced function.
Type:
  • string
Source:

(protected) obj_ :Object

The object hosting the method to displace.
Type:
  • Object
Source:

Methods

(static) after(fnnon-null, objnon-null, fnNamenon-null) → {EventHandle}

Executes the supplied method after the specified function.
Parameters:
Name Type Description
fn function the function to execute.
obj Object the object hosting the method to displace.
fnName string the name of the method to displace.
Source:
Returns:
Can be used to remove the listener.
Type
EventHandle

(static) alterReturn(value) → {Object}

Return an alterReturn object when you want to change the result returned from the core method to the caller.
Parameters:
Name Type Description
value any Return value passed to code that invoked the wrapped function.
Source:
Returns:
Type
Object

(static) before(fnnon-null, objnon-null, fnNamenon-null) → {EventHandle}

Executes the supplied method before the specified function.
Parameters:
Name Type Description
fn function the function to execute.
obj Object the object hosting the method to displace.
fnName string the name of the method to displace.
Source:
Returns:
Can be used to remove the listener.
Type
EventHandle

(static) halt(value) → {Object}

Return a halt object when you want to terminate the execution of all subsequent subscribers as well as the wrapped method if it has not executed yet.
Parameters:
Name Type Description
value any Return value passed to code that invoked the wrapped function.
Source:
Returns:
Type
Object

(static) inject(before, fnnon-null, objnon-null, fnNamenon-null) → {EventHandle}

Executes the supplied method before or after the specified function.
Parameters:
Name Type Description
before boolean determines when the listener is invoked.
fn function the function to execute.
obj Object the object hosting the method to displace.
fnName string the name of the method to displace.
Source:
Returns:
Can be used to remove the listener.
Type
EventHandle

(static) modify_(typenon-null, value) → {Object}

Returns object which instructs `exec` method to modify the return value or prevent default behavior of wrapped function.
Parameters:
Name Type Description
type string The type of modification to be made
value any Return value passed to code that invoked the wrapped function.
Source:
Returns:
Type
Object

(static) prevent() → {Object}

Return a prevent object when you want to prevent the wrapped function from executing, but want the remaining listeners to execute.
Source:
Returns:
Type
Object

createHandle(fnnon-null, beforenon-null) → {Object}

Creates handle for detaching listener from displaced function.
Parameters:
Name Type Description
fn function The listener
before boolean Determines when listener fires
Source:
Returns:
Type
Object

detach_(fnnon-null, beforenon-null)

Detaches listener from displaced function.
Parameters:
Name Type Description
fn function The listener
before boolean Determines when listener fires
Source:

exec(args*) → {any}

Parameters:
Name Type Description
args* any Arguments are passed to the wrapping and wrapped functions.
Source:
Returns:
Return value of wrapped function.
Type
any

register(fnnon-null, before) → {EventHandle}

Registers an AOP listener.
Parameters:
Name Type Description
fn function the function to execute.
before boolean determines when the listener is invoked.
Source:
Returns:
Can be used to remove the listener.
Type
EventHandle