# Yahoo! UI Library

### plugin 3.3.0

Yahoo! UI Library > plugin > Plugin.Base
Search:
Filters Show Private Show Protected Show Deprecated

## Class Plugin.Base - extends Base

Known Subclasses:
  DataTableSort DataTableDataSource DataSourceXMLSchema DataSourceArraySchema DataSourceJSONSchema Plugin.WidgetAnim DataTableScroll Plugin.ScrollViewPaginator Plugin.ScrollViewScrollbars DataSourceTextSchema

The base class for all Plugin instances.

### Properties

#### _handles - `private Array`

The list of event handles for event listeners or AOP injected methods applied by the plugin to the host object.

#### Plugin.Base.ATTRS - `static Object`

Object defining the set of attributes supported by the Plugin.Base class

#### Plugin.Base.NAME - `static String`

The string identifying the Plugin.Base class. Plugins extending Plugin.Base should set their own NAME value.

#### Plugin.NS - `static String`

The name of the property the the plugin will be attached to when plugged into a Plugin Host. Plugins extending Plugin.Base, should set their own NS value.

#### Properties inherited from Plugin.Host:

`PluginHost`

#### Properties inherited from Attribute:

``

#### Properties inherited from Base:

`name`

### Methods

#### afterHostEvent

`EventHandle afterHostEvent ( type , fn , context )`
Listens for the "after" moment of events fired by the host object. Listeners attached through this method will be detached when the plugin is unplugged.

Parameters:
  `type <String | Object>` The event type.
  `fn <Function>` The listener.
  `context <Object>` The execution context. Defaults to the plugin instance.

Returns: `EventHandle`
  handle The detach handle for the listener.

#### afterHostMethod

`EventHandle afterHostMethod ( method , fn , context )`
Injects a function to be executed after a given method on host object. The function will be detached when the plugin is unplugged.

Parameters:
  `method <String>` The name of the method to inject the function after.
  `fn <Function>` The function to inject.
  `context <Object>` The execution context. Defaults to the plugin instance.

Returns: `EventHandle`
  handle The detach handle for the injected function.

#### beforeHostMethod

`EventHandle beforeHostMethod ( method , fn , context )`
Injects a function to be executed before a given method on host object. The function will be detached when the plugin is unplugged.

Parameters:
  `method <String>` The name of the method to inject the function before.
  `fn <Function>` The function to inject.
  `context <Object>` The execution context. Defaults to the plugin instance.

Returns: `EventHandle`
  handle The detach handle for the injected function.

#### destructor

`void destructor ( )`
Destructor lifecycle implementation. Removes any event listeners or injected methods applied by the Plugin

#### doAfter

`EventHandle doAfter ( strMethod , fn , context )`
Listens for the "after" moment of events fired by the host, or injects code "after" a given method on the host.

Parameters:
  `strMethod <String>` The event to listen for, or method to inject logic after.
  `fn <Function>` The handler function. For events, the "after" moment listener. For methods, the function to execute after the given method is executed.
  `context <Object>` An optional context to call the handler with. The default context is the plugin instance.

Returns: `EventHandle`
  handle The detach handle for the listener.

#### doBefore

`EventHandle doBefore ( strMethod , fn , context )`
Listens for the "on" moment of events fired by the host, or injects code "before" a given method on the host.

Parameters:
  `strMethod <String>` The event to listen for, or method to inject logic before.
  `fn <Function>` The handler function. For events, the "on" moment listener. For methods, the function to execute before the given method is executed.
  `context <Object>` An optional context to call the handler with. The default context is the plugin instance.

Returns: `EventHandle`
  handle The detach handle for the handler.

#### initializer

`void initializer ( config )`
Initializer lifecycle implementation.

Parameters:
  `config <Object>` Configuration object with property name/value pairs.

#### onHostEvent

`EventHandle onHostEvent ( type , fn , context )`
Listens for the "on" moment of events fired by the host object. Listeners attached through this method will be detached when the plugin is unplugged.

Parameters:
  `type <String | Object>` The event type.
  `fn <Function>` The listener.
  `context <Object>` The execution context. Defaults to the plugin instance.

Returns: `EventHandle`
  handle The detach handle for the listener.

#### Methods inherited from EventTarget:

`_getType, _monitor, _parseType, addTarget, after, before, bubble, detach, detachAll, fire, getEvent, getTargets, on, once, parseType, publish, removeTarget, subscribe, unsubscribe, unsubscribeAll`

#### Methods inherited from Attribute:

`_addAttrs, _addLazyAttr, _defAttrChangeFn, _fireAttrChange, _getAttr, _getAttrCfg, _getAttrInitVal, _getAttrs, _getStateVal, _isLazyAttr, _normAttrVals, _protectAttrs, _set, _setAttr, _setAttrs, _setAttrVal, _setStateVal, addAttr, addAttrs, attrAdded, get, getAttrs, modifyAttr, removeAttr, reset, set, setAttrs`

#### Methods inherited from Plugin.Host:

`_destroyPlugins, _initPlugins, hasPlugin, plug, unplug`

#### Methods inherited from Base:

`_aggregateAttrs, _defDestroyFn, _defInitFn, _destroyHierarchy, _filterAttrCfs, _getAttrCfgs, _getClasses, _initHierarchy, _initHierarchyData, _preInitEventCfg, destroy, init, toString`

### Events

#### hostChange

`hostChange ( event )`
Fires when the value for the configuration attribute 'host' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### Events inherited from Base:

`destroy, destroyedChange, init, initializedChange,`

### Configuration Attributes

#### host `- writeonce Plugin.Host`

The plugin's host object.

#### Configuration attributes inherited from Base:

`destroyed initialized`

Copyright © 2011 Yahoo! Inc. All rights reserved.