Class: PluginLoader
@ima/core.PluginLoader
Plugin loader utility used to register external IMA.js plugins. This adds ability for external packages to automatically hook into several IMA.js application parts and automatically bootstrap certain settings.
Constructors
constructor
• Private
new PluginLoader()
Initializes the plugin loader.
This is private constructor and should not be used outside of this file. You should use the exported instance to register ima.js plugins.
Example
import { pluginLoader } from '@ima/core';
@private
Defined in
packages/core/src/pluginLoader.ts:26
Properties
_bootstrap
• Protected
Optional
_bootstrap: Bootstrap
Defined in
packages/core/src/pluginLoader.ts:14
_plugins
• Protected
_plugins: Record
<string
, { name
: string
; plugin
: InitPluginConfig
}>
Defined in
packages/core/src/pluginLoader.ts:10
Methods
getPlugins
▸ getPlugins(): { name
: string
; plugin
: InitPluginConfig
}[]
Returns array of registered IMA.js plugins.
Returns
{ name
: string
; plugin
: InitPluginConfig
}[]
Array of IMA.js plugins.
Defined in
packages/core/src/pluginLoader.ts:88
init
▸ init(bootstrap
): void
Initializes the plugin loader with bootstrap instance. Which is later used to handle dynamically loaded IMA.js plugins.
Parameters
Name | Type | Description |
---|---|---|
bootstrap | Bootstrap | App bootstrap instance. |
Returns
void
Defined in
packages/core/src/pluginLoader.ts:36
register
▸ register(name
, registerFn
): void
Registers plugin into IMA.js bootstrap sequence.
Parameters
Name | Type | Description |
---|---|---|
name | string | Plugin name. |
registerFn | (ns : Namespace ) => void | InitPluginConfig | Plugin initialization function. |
Returns
void
Example
pluginLoader.register('@ima/plugin-logger', ns => {
ns.set('ima.plugin.logger', logger);
return {
initSettings,
initServices,
initBind,
};
});