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
Configs
9Common
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.
Misc
The widget which this plugin is to attach to.
Other
Properties
14
Properties
14Common
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
Misc
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Other
Functions
28
Functions
28Misc
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.
Configuration
Events
Other
Events
5
Events
5Fired when the plugin/feature is disabled.
// Adding a listener using the "on" method
instancePlugin.on('disable', ({ source }) => {
});| Parameter | Type | Description |
|---|---|---|
source | InstancePlugin |
Fired when the plugin/feature is enabled.
// Adding a listener using the "on" method
instancePlugin.on('enable', ({ source }) => {
});| Parameter | Type | Description |
|---|---|---|
source | InstancePlugin |
Event handlers
5
Event handlers
5Called when the plugin/feature is disabled.
new InstancePlugin({
onDisable({ source }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | InstancePlugin |
Called when the plugin/feature is enabled.
new InstancePlugin({
onEnable({ source }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | InstancePlugin |