Extends
Methods
addDependency()
- Description:
Manually add a dependency to a given plugin. Usefull to require a plugin within a plugin
- Source:
- Overrides:
checkRegisteredPlugins()
- Description:
private
- Source:
getRegisteredPlugins() → {Array:.<string:>}
- Description:
Returns the list of the registered plugins ids
- Source:
- Overrides:
Returns:
onStateChange(callback, Function)
- Description:
Propagate a notification each time a plugin is updated (status or inner state). The callback will receive the list of all plugins as first parameter, and the plugin instance that initiated the state change event as second parameter.
In most cases, you should not have to rely on this method.
- Source:
- Overrides:
Example
const unsubscribe = client.pluginManager.onStateChange(pluginList, initiator => {
// log the current status of all plugins
for (let name in pluginList) {
console.log(name, pluginList[name].status);
}
// if the change was initiated by a plugin, log its status and state
if (initiator !== null) {
. console.log(initiator.name, initiator.status, initiator.state);
}
});
// stop listening for updates later
unsubscribe();
Parameters:
Name | Type | Description |
---|---|---|
callback |
client.PluginManager~onStateChangeCallback | server.PluginManager~onStateChangeCallback | Callback to be executed on state change |
Function |
client.PluginManager~deleteOnStateChangeCallback | client.PluginManager~deleteOnStateChangeCallback | to execute to listening for changes. |
register(id, factory, optionsopt, depsopt)
- Description:
Register a plugin into soundworks.
A plugin must always be registered both on client-side and on server-side
Refer to the plugin documentation to check its options and proper way of registering it.
- Source:
- Overrides:
- See:
Example
// client-side
client.pluginManager.register('user-defined-id', pluginFactory);
// server-side
server.pluginManager.register('user-defined-id', pluginFactory);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | Unique id of the plugin. Enables the registration of the same plugin factory under different ids. |
||
factory |
function | Factory function that returns the Plugin class. |
||
options |
object |
<optional> |
{}
|
Options to configure the plugin. |
deps |
array |
<optional> |
[]
|
List of plugins' names the plugin depends on, i.e. the plugin initialization will start only after the plugins it depends on are fully started themselves. |
Type Definitions
deleteOnStateChangeCallback()
- Description:
Delete the registered server.PluginManager~onStateChangeCallback.
- Source:
onStateChangeCallback(fullState, initiator)
- Description:
Callback executed when a plugin internal state is updated.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fullState |
object:.<server.Plugin#id:, server.Plugin:> | List of all plugins. |
initiator |
server.Plugin | null | Plugin that initiated the update or |