InstancePlugin

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 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.

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']
     };
  }
}

Configs

9

Common

disabled: Boolean= falseAlso a property

The plugin/feature disabled state.

For a feature that is off by default that you want to enable later during runtime, configure it with disabled : true.

const grid = new Grid({
     features : {
         featureName : {
             disabled : true // on and disabled, can be enabled later
         }
     }
});

// enable the feature
grid.features.featureName.disabled = false;

If the feature is disabled by default, and you want to include and enable the feature, configure it as true:

const grid = new Grid({
     features : {
         featureName : true // on and enabled, can be disabled later
     }
});

// disable the feature
grid.features.featureName.disabled = true;

If the feature is on by default, but you want to turn it off, configure it as false:

const grid = new Grid({
     features : {
         featureName : false // turned off, not included at all
     }
});

If the feature is enabled by default and you have no need of reconfiguring it, you can omit the feature configuration.

listenersEvents

Misc

The widget which this plugin is to attach to.

localeClassLocalizable
localizableLocalizable

Other

Properties

14

Common

disabled: Boolean= falseAlso a config

The plugin/feature disabled state.

For a feature that is off by default that you want to enable later during runtime, configure it with disabled : true.

const grid = new Grid({
     features : {
         featureName : {
             disabled : true // on and disabled, can be enabled later
         }
     }
});

// enable the feature
grid.features.featureName.disabled = false;

If the feature is disabled by default, and you want to include and enable the feature, configure it as true:

const grid = new Grid({
     features : {
         featureName : true // on and enabled, can be disabled later
     }
});

// disable the feature
grid.features.featureName.disabled = true;

If the feature is on by default, but you want to turn it off, configure it as false:

const grid = new Grid({
     features : {
         featureName : false // turned off, not included at all
     }
});

If the feature is enabled by default and you have no need of reconfiguring it, you can omit the feature configuration.

Class hierarchy

isInstancePlugin: Boolean= truereadonly
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
isInstancePlugin: Boolean= truereadonlystatic
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
isEventsEvents
isLocalizableLocalizable

Misc

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

localeHelperLocalizable
localeManagerLocalizable

Lifecycle

configBase

Other

Functions

28

Misc

Called when disabling/enabling the plugin/feature, not intended to be called directly. To enable or disable a plugin/feature, see disabled.

By default removes the cls of the plugin from its client. Override in subclasses to take any other actions necessary.

initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Other

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

5

Fired when the plugin/feature is disabled.

// Adding a listener using the "on" method
instancePlugin.on('disable', ({ source }) => {

});
ParameterTypeDescription
sourceInstancePlugin

Fired when the plugin/feature is enabled.

// Adding a listener using the "on" method
instancePlugin.on('enable', ({ source }) => {

});
ParameterTypeDescription
sourceInstancePlugin
catchAllEvents
destroyEvents

Event handlers

5

Called when the plugin/feature is disabled.

new InstancePlugin({
    onDisable({ source }) {

    }
});
ParameterTypeDescription
sourceInstancePlugin

Called when the plugin/feature is enabled.

new InstancePlugin({
    onEnable({ source }) {

    }
});
ParameterTypeDescription
sourceInstancePlugin
onDestroyEvents

Typedefs

1