@ima/core
Version:
IMA.js framework for isomorphic javascript application
62 lines • 1.9 kB
TypeScript
import { Bootstrap, InitPluginConfig } from './Bootstrap';
import { Namespace } from './Namespace';
/**
* 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.
*/
export declare class PluginLoader {
protected _plugins: Record<string, {
name: string;
plugin: InitPluginConfig;
}>;
protected _bootstrap?: Bootstrap;
/**
* 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
*/
constructor();
/**
* Initializes the plugin loader with bootstrap instance. Which is later used
* to handle dynamically loaded IMA.js plugins.
*
* @param bootstrap App bootstrap instance.
*/
init(bootstrap: Bootstrap): void;
/**
* Registers plugin into IMA.js bootstrap sequence.
*
* @example
* pluginLoader.register('@ima/plugin-logger', ns => {
* ns.set('ima.plugin.logger', logger);
*
* return {
* initSettings,
* initServices,
* initBind,
* };
* });
*
* @param {string} name Plugin name.
* @param {function} registerFn Plugin initialization function.
*/
register(name: string, registerFn: (ns: Namespace) => InitPluginConfig | void): void;
/**
* Returns array of registered IMA.js plugins.
*
* @returns {Array} Array of IMA.js plugins.
*/
getPlugins(): {
name: string;
plugin: InitPluginConfig;
}[];
}
export declare const pluginLoader: PluginLoader;
//# sourceMappingURL=pluginLoader.d.ts.map