Show:

Allows for the insertion of methods that are executed before or after a specified method

Index

Methods

Properties

Methods

_inject

(
  • when
  • fn
  • obj
  • sFn
  • c
)
EventHandle private static

Execute the supplied method before or after the specified function. Used by <code>before</code> and <code>after</code>.

Parameters:

  • when String

    before or after

  • fn Function

    the function to execute

  • obj Object

    the object hosting the method to displace

  • sFn String

    the name of the method to displace

  • c Object

    The execution context for fn

Returns:

EventHandle:

handle for the subscription

after

(
  • fn
  • obj
  • sFn
  • c
  • arg
)
EventHandle static

<p>Execute the supplied method after the specified function. Wrapping function may optionally return an instance of the following classes to further alter runtime behavior:</p> <dl> <dt></code>Y.Do.Halt(message, returnValue)</code></dt> <dd>Immediatly stop execution and return <code>returnValue</code>. No other wrapping functions will be executed.</dd> <dt></code>Y.Do.AlterReturn(message, returnValue)</code></dt> <dd>Return <code>returnValue</code> instead of the wrapped method's original return value. This can be further altered by other after phase wrappers.</dd> </dl>

<p>The static properties <code>Y.Do.originalRetVal</code> and <code>Y.Do.currentRetVal</code> will be populated for reference.</p>

Parameters:

  • fn Function

    the function to execute

  • obj Object

    the object hosting the method to displace

  • sFn String

    the name of the method to displace

  • c Object

    The execution context for fn

  • arg Mixed multiple

    0..n additional arguments to supply to the subscriber

Returns:

EventHandle:

handle for the subscription

before

(
  • fn
  • obj
  • sFn
  • c
  • arg
)
EventHandle static

<p>Execute the supplied method before the specified function. Wrapping function may optionally return an instance of the following classes to further alter runtime behavior:</p> <dl> <dt></code>Y.Do.Halt(message, returnValue)</code></dt> <dd>Immediatly stop execution and return <code>returnValue</code>. No other wrapping functions will be executed.</dd> <dt></code>Y.Do.AlterArgs(message, newArgArray)</code></dt> <dd>Replace the arguments that the original function will be called with.</dd> <dt></code>Y.Do.Prevent(message)</code></dt> <dd>Don't execute the wrapped function. Other before phase wrappers will be executed.</dd> </dl>

Parameters:

  • fn Function

    the function to execute

  • obj Object

    the object hosting the method to displace

  • sFn String

    the name of the method to displace

  • c Object

    The execution context for fn

  • arg Mixed multiple

    0..n additional arguments to supply to the subscriber when the event fires.

Returns:

EventHandle:

handle for the subscription

detach

(
  • handle
)
static

Detach a before or after subscription.

Parameters:

Properties

currentRetVal

Unknown static

Defined in yui3/src/event-custom/js/event-do.js:180

Available since 3.2.0

Contains the current state of the return value, consumable by 'after' event listeners, and updated if an after subscriber changes the return value generated by the wrapped function.

objs

Unknown deprecated static

Defined in yui3/src/event-custom/js/event-do.js:20

Deprecated: Since 3.6.0. The `_yuiaop` property on the AOP'd object replaces the role of this property, but is considered to be private, and is only mentioned to provide a migration path. If you have a use case which warrants migration to the _yuiaop property, please file a ticket to let us know what it's used for and we can see if we need to expose hooks for that functionality more formally.

Cache of objects touched by the utility

originalRetVal

Unknown static

Defined in yui3/src/event-custom/js/event-do.js:171

Available since 3.2.0

Contains the return value from the wrapped method, accessible by 'after' event listeners.