Class PluginInvokeSupport
Implements
Index
Constructors
Accessors
Methods
Constructors
constructor
- new
Plugin (pluginManager): PluginInvokeSupportInvoke Support Create PluginInvokeSupport
Parameters
- pluginManager: PluginManager
The plugin manager to associate.
Returns PluginInvokeSupport
- pluginManager: PluginManager
Accessors
isDestroyed
- get isDestroyed(): boolean
Returns whether the associated plugin manager has been destroyed.
Returns boolean
Returns whether the plugin manager has been destroyed.
options
- get options(): PluginManagerOptions
Returns the associated plugin manager options.
Returns PluginManagerOptions
The associated plugin manager options.
pluginManager
- get pluginManager(): PluginManager
Gets the associated plugin manager.
Returns PluginManager
The associated plugin manager
Methods
destroy
getMethodNames
- get
Method (opts?): string[]Names Returns method names for a specific plugin, list of plugins, or all plugins. The enabled state can be specified along with sorting methods by plugin name.
Parameters
Optional
opts: {
enabled?: boolean;
plugins?: string | Iterable<string, any, any>;
}Options object. If undefined all plugin data is returned.
Optional
enabled?: booleanIf enabled is a boolean it will return plugin methods names given the respective enabled state.
Optional
plugins?: string | Iterable<string, any, any>Plugin name or iterable list of names.
Returns string[]
A list of method names
hasMethod
invoke
- invoke(opts): void
This dispatch method simply invokes any plugin targets for the given method name.
Parameters
- opts: {
args?: any[];
method: string;
plugins?: string | Iterable<string, any, any>;
}Options object.
Optional
args?: any[]Method arguments. This array will be spread as multiple arguments.
method: string
Method name to invoke.
Optional
plugins?: string | Iterable<string, any, any>Specific plugin name or iterable list of plugin names to invoke.
Returns void
- opts: {
invokeAsync
- invoke
Async (opts): Promise<any> This dispatch method is asynchronous and adds any returned results to an array which is resolved via Promise.all Any target invoked may return a Promise or any result.
Parameters
- opts: {
args?: any[];
method: string;
plugins?: string | Iterable<string, any, any>;
}Options object.
Optional
args?: any[]Method arguments. This array will be spread as multiple arguments.
method: string
Method name to invoke.
Optional
plugins?: string | Iterable<string, any, any>Specific plugin name or iterable list of plugin names to invoke.
Returns Promise<any>
A single result or array of results.
- opts: {
invokeAsyncEvent
- invoke
Async (opts): Promise<object>Event This dispatch method synchronously passes to and returns from any invoked targets a PluginEvent.
Parameters
- opts: {
copyProps?: object;
method: string;
passthruProps?: object;
plugins?: string | Iterable<string, any, any>;
}Options object.
Optional
copyProps ?: objectProperties that are copied.
method: string
Method name to invoke.
Optional
passthruProps ?: objectProperties that are passed through.
Optional
plugins?: string | Iterable<string, any, any>Specific plugin name or iterable list of plugin names to invoke.
Returns Promise<object>
The PluginEvent data.
- opts: {
invokeSync
- invoke
Sync (opts): any This dispatch method synchronously passes back a single value or an array with all results returned by any invoked targets.
Parameters
- opts: {
args?: any[];
method: string;
plugins?: string | Iterable<string, any, any>;
}Options object.
Optional
args?: any[]Method arguments. This array will be spread as multiple arguments.
method: string
Method name to invoke.
Optional
plugins?: string | Iterable<string, any, any>Specific plugin name or iterable list of plugin names to invoke.
Returns any
A single result or array of results.
- opts: {
invokeSyncEvent
- invoke
Sync (opts): objectEvent This dispatch method synchronously passes to and returns from any invoked targets a PluginEvent.
Parameters
- opts: {
copyProps?: object;
method: string;
passthruProps?: object;
plugins?: string | Iterable<string, any, any>;
}Options object.
Optional
copyProps ?: objectProperties that are copied.
method: string
Method name to invoke.
Optional
passthruProps ?: objectProperties that are passed through.
Optional
plugins?: string | Iterable<string, any, any>Specific plugin name or iterable list of plugin names to invoke.
Returns object
The PluginEvent data.
- opts: {
setEventbus
- set
Eventbus (opts): void Sets the eventbus associated with this plugin manager. If any previous eventbus was associated all plugin manager events will be removed then added to the new eventbus. If there are any existing plugins being managed their events will be removed from the old eventbus and then
onPluginLoad
will be called with the new eventbus.Parameters
Returns void
setOptions
- set
Options (options): void Set optional parameters.
Parameters
- options: PluginManagerOptions
Defines optional parameters to set.
Returns void
- options: PluginManagerOptions
PluginInvokeSupport adds direct method invocation support to PluginManager via the eventbus and alternately through a wrapped instance of PluginManager depending on the use case.
There are two types of invocation methods the first spreads an array of arguments to the invoked method. The second constructs a PluginInvokeEvent to pass to the method with a single parameter.
TODO: more info and wiki link
When added to a PluginManager through constructor initialization the following events are registered on the plugin manager eventbus:
plugins:async:invoke
- PluginInvokeSupport#invokeAsyncplugins:async:invoke:event
- PluginInvokeSupport#invokeAsyncEventplugins:get:method:names
- PluginInvokeSupport#getMethodNamesplugins:has:method
- PluginInvokeSupport#hasMethodplugins:invoke
- PluginInvokeSupport#invokeplugins:sync:invoke
- PluginInvokeSupport#invokeSyncplugins:sync:invoke:event
- PluginInvokeSupport#invokeSyncEventExample