v7.3.0
SupportExamplesFree Trial

InstancePlugin
Plugin

Base class for plugins. Published functions will be available from the other class. this in published functions is referenced to the plugin, access the other class using this.client.

Observe that a plugin doesn't apply itself on class level but instead on instance level. Plugin is its own instance that can have own functions and data that is not exposed to target class.

For a comprehensive guide on creating custom features (plugins), see the Creating custom features guide.

Functions can be published in four ways:

  • assign (when function is not already available on target)
  • before (when function is already available on target, will be called before original function)
  • after (when function is already available on target, will be called after original function)
  • override (replaces function on target, but old function can be reached)

To configure which functions get published and in what way, specify pluginConfig getter on plugin:

class Sort extends InstancePlugin {
  static get pluginConfig {
     return {
         before   : ['init'],
         after    : ['destroy', 'onElementClick'],
         override : ['render']
     };
  }
}

Useful configs and properties

Config / Property Description
disabled The plugin disabled state
client Reference to the owning widget

See also

  • Widget - Base widget that hosts plugins
  • Pluggable - Mixin that enables plugin support
No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • Internal listeners, that cannot be removed by the user.

  • client : Widget
    ADVANCED

    The widget which this plugin is to attach to.

    Has a corresponding runtime client property.

  • Set to false to disable localization of this object.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isInstancePlugin : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of InstancePlugin class, or subclass thereof.
  • isLocalizable : Booleantrue
    READONLY
    static
    ADVANCED
    Localizable
    Identifies an object as an instance of Localizable class, or subclass thereof.
  • properties : Object
    internal
    static
    Base

    A class property getter for the default values of internal properties for this class.

  • emptyArray : Array
    internal
    READONLY
    Base

    An empty array that can be used as a default value.

  • emptyObject : Object
    internal
    READONLY
    Base

    An empty object that can be used as a default value.

  • isInstancePlugin : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of InstancePlugin class, or subclass thereof.
  • config : Object
    READONLY
    ADVANCED
    Base

    Returns a copy of the full configuration which was used to configure this object.

  • isConstructing : Boolean
    READONLY
    ADVANCED
    Base

    This property is set to true before the constructor returns.

  • isDestroying : Boolean
    READONLY
    ADVANCED
    Base

    This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • client : Widget
    READONLY
    ADVANCED

    The Widget which was passed into the constructor, which is the Widget we are providing extra services for.

    Has a corresponding client config.

  • Get the global LocaleHelper

  • Get the global LocaleManager

Functions

Functions are methods available for calling on the class
  • onClassMixedIn( )
    internal
    static
    Base

    This optional class method is called when a class is mixed in using the mixin() method.

  • initClass( )
    static
    ADVANCED
    Base

    Registers this class type with its Factory

  • updateKeyMap( )
    private

    This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.

  • Internal function used to hook destroy() calls when using thisObj

  • Internal function used restore hooked destroy() calls when using thisObj

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

    Internal function used to run a callback function after an event is triggered

  • Removes all listeners registered to this object by the application.

Events

Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

Event handlers

Event handlers are callbacks called as a result of certain actions in this class

Type definitions

Source path

Core/mixin/InstancePlugin.js

Contents