Plugins
The Plugins module provides a generic API which can be used in conjunction with custom plugins.
All plugins should have a name and a type. The name is used to identify the plugin, and the type is used for grouping purposes. It is a good idea to group the plugins by their type, and use a unique name for each one.
Members
onEvent
Signal fired when a plugin specific event occurs. The listener will be passed the following arguments:
- pluginType: The type of the plugin that emitted the signal.
- pluginName: The name of the plugin that emitted the signal.
- event: A Number that may be used as an enumeration to identify the event.
- data: A String containing event related data. Depending on the event, it may be used as String literal or fed to JSON.parse() to create more sophisticated objects.
Methods
invoke(pluginType, pluginName, methodName, args)
Invokes the desired plugin method. The plugin in which the method will be invoked is the one with the same type and name as the ones provided.
Parameters:
| Name | Type | Description |
|---|---|---|
pluginType | String | The plugin type. |
pluginName | String | The plugin name. |
methodName | String | The name of the method to invoke. |
args | Array | The arguments of the method to invoke. |
Returns:
| Type | Description |
|---|---|
| A promise. | The listener will be passed the following arguments: - result: A String with the returned value of the invoked method. Depending on the invoked method, it may be used as String literal or fed to JSON.parse() to create more sophisticated objects. |