IPlugin
It is an Interface used to create a Plugin. If you want to create a plugin, you have to implement your class with the IPlugin interface.
Variables
It contains one variable pluginStore
which is is used to store the PluginStore for the given plugin.
Methods:
getPluginName
Gives you the name and version of the plugin.
Arguments
(void
)
Returns
(string
) of the pattern "<plugin_name>@<plugin_version>"
Example
getPluginName(): string {
return "ClickMe@1.1.0";
}
getDependencies
Gives you the plugins which have to be installed before the plugin itself.
Arguments
(void
)
Returns
(Array
): An array of Plugins in the string format.
Example
getDependencies():void {
return ["plugin1@1.1.0","plugin2@0.1.0"];
}
init
It is used to initialise the plugin class.
Arguments
(PluginStore
) : It is an instance of the PluginStore which installs the plugin class.
Returns
(void
)
Example
init(pluginStore: PluginStore): void {
this.pluginStore = pluginStore;
}
activate
It performs operations to activate features which can be used once the plugin is active.
Arguments
(void
)
Returns
(void
)
Example
activate(): void {
this.pluginStore.addFunction(
`${this.namespace}.sendAlert`,
(msg: string) => {
alert(msg);
}
);
}
deactivate
It performs operations to remove features once the plugin gets deactivated.
Arguments
(void
)
Returns
(void
)
Example
deactivate(): void {
this.pluginStore.removeFunction(`${this.namespace}.sendAlert`);
}